rjsx
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

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>
    </>
  );
}

Readme

Keywords

Package Sidebar

Install

npm i rjsx

Weekly Downloads

0

Version

1.0.1

License

none

Unpacked Size

74.5 kB

Total Files

8

Last publish

Collaborators

  • ameegle