An experimental, lightweight React alternative.
Table of contents:
Install:
yarn add @rkrupinski/react
Make sure to set:
{
"jsx": "react"
}
in your tsconfig.json
-> "compilerOptions"
.
Now you're all set:
/* @jsx createElement */
/* @jsxFrag Fragment */
import {
render,
useState,
useEffect,
createElement,
Fragment,
type FC,
} from "@rkrupinski/react";
const App: FC = () => {
const [clicked, setClicked] = useState(0);
useEffect(() => {
console.log(`Clicked ${clicked} times`);
}, [clicked]);
return (
<>
<h1>Hello!</h1>
<button
onClick={() => {
setClicked((c) => c + 1);
}}
>
{clicked}
</button>
</>
);
};
const root = document.querySelector("#root") as HTMLElement;
render(<App />, root);
Read about React first, then come back here 🙏.
Name | React | Caveats |
---|---|---|
createElement |
createElement |
|
Fragment |
Fragment |
|
Name | React | Caveats |
---|---|---|
render |
render |
|
unmountAt |
unmountComponentAtNode | - |
Name | React | Caveats |
---|---|---|
useState |
useState | - |
useMemo |
useMemo | - |
useCallback |
useCallback | - |
useEffect |
useEffect | - |