Hacker News new | ask | show | jobs
by baron816 1914 days ago
I created a library that simplifies working with Context, and won't rerender the whole app when a Provider rerenders from a state change. https://github.com/baron816/galactic-context

You can play around with a demo here https://codesandbox.io/s/galactic-context-demo-eqkrp

1 comments

Nice! Seems more "raw context" than most of the simple state management libraries I've seen so far!

I also created a library for state management including Context, the main goal as well was not to rerender everything when a fragment of a Context changes (which is IMHO the main limitation of using Context):

https://statux.dev/

    const Counter = () => {
      const [counter, setCounter] = useStore('counter');
      const onClick = () => setCounter(counter + 1);
      return <button onClick={onClick}>{counter}</button>;
    }

    // ...

    const App = () => (
      <Store counter={0}>
        // ... App
      </Store>
    );
There's probably dozens like ours! It's fun, simplifies and improves development and it's not so heavy-handed as Redux (+ all the concepts behind).