We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unstated is a cool state manager based on the new Context API with a polyfill for older React versions. More info here: https://github.com/jamiebuilds/unstated
unstated
Container:
import { Container } from 'unstated'; type CounterState = { count: number }; class CounterContainer extends Container<CounterState> { state = { count: 0 }; increment() { this.setState({ count: this.state.count + 1 }); } decrement() { this.setState({ count: this.state.count - 1 }); } }
Subscribed Component:
import { Subscribe } from 'unstated'; const Counter = () => { return ( <Subscribe to={[CounterContainer]}> {counter => ( <div> <button onClick={() => counter.decrement()}>-</button> <span>{counter.state.count}</span> <button onClick={() => counter.increment()}>+</button> </div> )} </Subscribe> ); }
Provider Component:
import { Provider } from 'unstated'; const ProviderComponent = () => { return ( <Provider> <Counter /> </Provider> ); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
unstated
is a cool state manager based on the new Context API with a polyfill for older React versions.More info here: https://github.com/jamiebuilds/unstated
Container:
Subscribed Component:
Provider Component:
The text was updated successfully, but these errors were encountered: