Observer is used to replace useObserver and can work with function components. Compare these two code snippets:
const BugsHeader = observer(() => {
const store = React.useContext(StoreContext);
return (<h1>{store.bugsCount} Bugs!</h1>)
});
const BugsHeader = () => {
const store = React.useContext(StoreContext);
return useObserver(()=> <h1>{store.bugsCount} Bugs!</h1>);
}
At first used the second code block and it worked. Then I replaced the “userObserver” with “Observer” and it throwed error. It takes me a while to find out how to fix it by using the first code block.