rjsx
v1.0.1
Published
一个极简的试图响应式库
Downloads
6
Readme
jsx runtime
一个简易的jsx运行时
安装
npm install rjsx
使用
在tsconfig.json
的compilerOptions
下添加:
{
"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>
</>
);
}