Mobx React
mobx-react
React bindings for MobX. Create fully reactive components.
State Management
mobx
mobservable
react-component
react
reactjs
reactive
mobx-react
State Management
javascript
npm
Stars
28k
Weekly
2.2M
Open issues
58
Bundle
~25 kB
Installation
npm install mobx-reactCode example
import { create } from "mobx-react";
const useStore = create((set) => ({
count: 0,
inc: () => set((s) => ({ count: s.count + 1 })),
}));
export function Example() {
const { count, inc } = useStore();
return (
<button type="button" onClick={inc}>
Count: {count}
</button>
);
}Pros & cons
Pros
- Actively maintained by Michel Weststrate
- 2.2M weekly downloads. Battle tested
- First-class TypeScript definitions
- MIT licensed
Considerations
- Adds roughly ~25 kB to your bundle
- Needs client-only rendering in SSR frameworks
- Not supported in React Native
- 58 open issues on GitHub