1.0.1 • Published 1 year ago

rjsx v1.0.1

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

jsx runtime

一个简易的jsx运行时

安装

npm install rjsx

使用

tsconfig.jsoncompilerOptions下添加:

{
  "compilerOptions":{
    "jsx": "react-jsx",
    //"jsxFactory": "rjsx.createElement",
    //"jsxFragmentFactory": "rjsx.Fragment",
    "jsxImportSource": "rjsx",
    "types": [
      "rjsx/types"
    ]
  }
}

示例

import { useEffect, useState } from 'rjsx';

const App({ color }: any) => {
  const [tick, setTick] = useState(0);
  useEffect(() => {
    const interval = setInterval(() => {
      setTick(tick + 1);
    }, 1000);
    return () => clearInterval(interval);
  }, [tick]);

  return (
    <>
      <span style={{ color }}>Seconds:</span>
      <span>{tick}</span>
    </>
  );
}
1.0.1

1 year ago

1.0.0

1 year ago

0.0.46

2 years ago