2.0.0-alpha.0 • Published 7 months ago

@alesmenzel/nuclear-react v2.0.0-alpha.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

⚛️ Nuclear React

Nuclear Core's bindings for React.

Installation

npm install @alesmenzel/nuclear-core @alesmenzel/nuclear-react

Usage

See @alesmenzel/nuclear-core documentation.

useAtom

Hook useAtom is used to subscribe React component to the atom's state. Whenever the atom's value changes, the subscribed React components will re-render as well.

import { atom } from '@alesmenzel/nuclear-core';
import { useAtom } from '@alesmenzel/nuclear-react';

const Counter = () => {
  const [count, setCount, countAtom] = useAtom(() => atom(100));

  return (
    <div>
      <pre>{count}</pre>
      <button onClick={() => setCount((count) => count + 1)}>Increment by 1</button>
    </div>
  );
};