reactjsmobxmobx-react

Mobx & React - the proper place in the code for the configure object


I have maybe a silly question: where is the best way to put a configure object for Mobx in the project? Or the enableStaticRendering option?

In the 'template' file, using for server side rendering? main.ts - the 'first' file? Or in App.tsx?

My project (random order):

I know what should I use. But I don't know how to do it properly and where to put in the code.

I'm still new in programming so I've tried to put configure object or the enableStaticRendering option in random places in my code and watch what happens. It's not the best way, I know, but I didn't find any exact guidance in official documentation or on the internet.


Solution

  • I don't think there is a best way, but server side entry file is a good place to call it there, yes. Overall it does not matter too much, just be sure to call it before you actually render any of your observers.

    configure can be placed in App.tsx because usually you have the same configuration for SSR and CSR