Good question! If you're just going to deploy your React app as a static website i.e. client-side rendering, you can directly import the store instance it wouldn't make any difference, but for server-side rendering, passing the store via context is essential. I will also be making an example on server-side rendering with MobX
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I have question.
TodoStore.js
could create new Todos object and exports it. Andindex.js
could simply import thatstore
and use it (I test it and it works).Is there any reason why use
useContext
if it works without it?Good question! If you're just going to deploy your React app as a static website i.e. client-side rendering, you can directly import the store instance it wouldn't make any difference, but for server-side rendering, passing the store via context is essential. I will also be making an example on server-side rendering with MobX