Get started with mobx-react CDN
MIT licensed
MobX-React is a library that integrates MobX state management with React components, allowing real-time, reactive component rendering based on observable state.
Tags:- mobx
- mobservable
- react-component
- react
- reactjs
- reactive
Stable version
Copied!
How to start using mobx-react CDN
import React from 'react';
import { observer, inject } from 'mobx-react';
import { observable } from 'mobx';
// Create a simple store
class CounterStore {
@observable count = 0;
increment = () => {
this.count++;
};
}
const counterStore = new CounterStore();
// Wrap your component in an observer to react to store changes
@observer
class Counter extends React.Component {
render() {
return (
<div>
<button onClick={() => this.props.counterStore.increment()}>
Click me!
</button>
<p>Count: {this.props.counterStore.count}</p>
</div>
);
}
}
// Use inject to provide the store to your component
@inject('counterStore')
class App extends React.Component {
render() {
return <Counter counterStore={this.props.counterStore} />;
}
}
// Render the app
export default App;
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
All versions
0.1.2
0.1.3
0.1.4
0.1.5
0.1.6
0.1.7
0.1.8
0.2.0
0.2.1
0.2.2
0.2.3
1.0.0
1.0.1
1.0.2
1.0.3
2.0.0
2.0.1
2.1.0
2.1.1
2.1.2
2.1.3
2.1.4
2.1.5
3.0.0
3.0.1
3.0.2
3.0.3
3.0.4
3.0.5
3.1.0
3.2.0
3.3.0
3.3.1
3.4.0
3.4.0-beta.1
3.5.0
3.5.1
3.5.2
3.5.2-alpha.1
3.5.3
3.5.4
3.5.5
3.5.6
3.5.7
3.5.8
3.5.9
4.0.0
4.0.0-beta.1
4.0.0-beta.2
4.0.0-rc.1
4.0.0-rc.2
4.0.0-rc.3
4.0.0-rc.4
4.0.1
4.0.2
4.0.2-rc
4.0.3
4.0.3-rc
4.0.4
4.1.0
4.1.1
4.1.2
4.1.3
4.1.4
4.1.5
4.1.6
4.1.7
4.1.8
4.2.1
4.2.2
4.3.0-rc.1
4.3.1
4.3.2
4.3.2-rc.1
4.3.3
4.3.4
4.3.5
4.4.0
4.4.1
4.4.2
4.4.3
5.0.0
5.0.0-beta.1
5.0.0-be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