mobx-observer
Required methods
componentDidMount
componentWillUnmount
render
If your component has these lifecycle methods, mobx-observer will be able to subscribe/unsubscribe to changes on your mobx observables. Which means you can use this not only with react, but also with inferno, preact, react-lite.
For React, it is safer to use the official mobx-react.
Install
npm i mobx-observer -S
Usage
@observer { return <div onClick= { stateval++ }> <span>Counter is at: stateval </span> </div> } // stateless component style // you only need to do this once, not for every component const Counter =