Redity Is a library for render control. Intended to have states outside the component tree.
npm install redity
Read the documentation here.
// controller.js
import { render } from "redity";
export const KEYNAME = "MY_KEYNAME";
export const store = {
message: "",
};
export function handleClick() {
store.message = "Welcome to Redity!";
render(KEYNAME);
}
import { useRender } from "redity";
import { store, handleClick, KEYNAME } from "./controller";
export default function MyComponent() {
useRender(KEYNAME);
return (
<div>
<p>{store.message}</p>
<button onClick={handleClick}>Click me! :D</button>
</div>
);
}
Requirements: react@^16.8.0