luciex icon indicating copy to clipboard operation
luciex copied to clipboard

React Bindings

Open shadowtime2000 opened this issue 5 years ago • 2 comments

Possible usage:

import { Atom } from "luciex";
import { useAtom } from "luciex-react";

function Counter({ countAtom }) {
	const increment = useCallback((num) => num + 1);
	const [val, dispatch] = useAtom(countAtom);

	return (
		<>
			<div>Count: {val}</div>
			<button onClick={() => dispatch(increment)}>Increment!</button>
		</>
	)
}

shadowtime2000 avatar Nov 28 '20 03:11 shadowtime2000

This could work

aidenybai avatar Nov 28 '20 08:11 aidenybai

I could do a fake useAtom where it doesn't link at all to the actual global state and it uses it's own copy, or I could looking into subscribing forced renders.

shadowtime2000 avatar Nov 28 '20 10:11 shadowtime2000