mobx-starter icon indicating copy to clipboard operation
mobx-starter copied to clipboard

onEnter is only called on '/' path

Open jegarne opened this issue 7 years ago • 2 comments

Is this intentional? Is the idea that you should build any state in the initial page load? Or would you add an onEnter method to all your components and call browse() on any store data they require. Admittedly I'm still getting my head around how this works.

Logging the branches variable from render.js to console looks like it only ever matches on '/'.

jegarne avatar Dec 31 '17 00:12 jegarne

So this is actually not related to the path, onEnter does get called on the new components I added but only if I refresh the page, so it looks like this is related to the other bug "onEnter not called on client"

Update: yes, it does seem to be related to the paths. I renamed the path in src/config/routes.js from

{ path: '/', component: Home },

to

{ path: '/home', component: Home },

This appears to be what allowed to let onEnter be called on the other routes/components that I had added as maybe having a '/' route was somehow not letting them get called. Again, onEnter only gets run on the server, but that wasn't even happening on components other than the one mapped to '/' before.

jegarne avatar Dec 31 '17 01:12 jegarne

I confirm, onEnter is not isomorphic. It gets called server side but doesn't get called client side. I hope someone could make it really isomorphic.

salembaira avatar Mar 15 '18 16:03 salembaira