import { Observer, useLocalObservable } from 'mobx-react-lite';
function App() {
const { count, decrement, increment } = useLocalObservable(() => ({
count: 0,
increment() { this.count++ },
decrement() { this.count-- },
}));
return (
<div>
<Observer>{() => (<div>{count}</div>)}</Observer>
<button onClick={() => { decrement() }} >decrement</button>
<button onClick={() => { increment() }} >increment</button>
</div>
);
}
Observer not working with useLocalObservable.when I click on the buttons nothing is updated. What is the reason ?