olebedev / go-starter-kit

[abandoned] Golang isomorphic react/hot reloadable/redux/css-modules/SSR starter kit
Other
2.82k stars 359 forks source link

Why are you skipping the first call to onEnter? #70

Closed tanis2000 closed 7 years ago

tanis2000 commented 7 years ago

I am trying to understand this part of the code:

https://github.com/olebedev/go-starter-kit/blob/master/client/router/routes.js#L18

Why are you skipping the first call to the onEnter function on the components? I feel like this is leading to some weird errors on my side. Maybe it's not related, but I'm not sure.

I added JWT authentication and there's a login component on the homepage. When I login successfully, it redirects to a new page (called gallery in my case) where the onEnter function actually grabs some data from an authenticated web service.

It looks like the call to that web service is being skipped. If I go back to the homepage and login again (and thus get redirected to the gallery page) this time it works fine.

Maybe that's completely unrelated but eventually you might know what's going on. Cheers!

olebedev commented 7 years ago

Hi @tanis2000,

It's needed b/c for the first run at the client side, we already have HTML markup with some sort of data, fetched for this page at the server side. We already have all the data to render the page. So, we skip this.
But, actually, it's a react-router issue. React router renders

tanis2000 commented 7 years ago

Thanks for the explanation!