mhaagens / lazy-route

Lazy/async route loading for React Router 4 through System.import
57 stars 7 forks source link

It works with server side rendering? #1

Closed cloud-walker closed 7 years ago

cloud-walker commented 7 years ago

I'm investigating on this topic too, but my solution is not working on the server side

cpeddecord commented 7 years ago

it's only using componentDidMount, it won't load on the server.

mhaagens commented 7 years ago

Yeah, this doesn't work for server side rendering. A possible enhancement would be to check for an environment variable such as BUILD_TARGET=server and then run require on the server, which is what I'm doing in my projects at the moment. I plan on making an SSR branch of this component, I'll let you know once it's ready for testing.