2.0.0 • Published 6 years ago

hook-state v2.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

hook-state

NOTE: The original version of this library was based on Redux. If you want a redux solution for state management with hooks, you can use use-substate

An experimental hook-based state layer for React that allows sharing state between components.

npm install hook-state

Example

Provider:

import { Provider } from 'hook-state';

<Provider>
    <App />
</Provider>;

State reader:

import { useReader } from 'hook-state';

function MyComponent() {
    const name = useReader('name');

    return <div>My name is {name}</div>;
}

State writer:

import { useWriter } from 'hook-state';

function ChangeName() {
    const [name, setName] = useWriter('name', '');

    return (
        <div>
            Change name: <input value={name} onChange={e => setName(e.target.value)} />
        </div>
    );
}
2.0.0

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago