Closed jedwards1211 closed 8 years ago
What's your rationale here? Why go from async to sync?
Ah, nevermind – I see you're using the loader. It's a little less explicit. Are there other advantages?
@jordanh not really, just prettier code, and I figured since I would want to be using this loader for my own new routes (for the sake of less typing) I might as well PR this pattern into the skeleton
@jordanh ideally one would make something similar to react-loader
that displays a loading component while fetching the chunk. It should get the loading component from context so that it's skinnable.
That's an neat approach, but I'm hesitant to merge it because it's less expressive than what we've got. React-router has a predefined API for async routes. Making a synchronous API behave in an async fashion, IMHO, is a code smell because the async nature should be a property of the function, not the location. That reduced code comprehension will confuse the heck out of a noobie to the codebase who assumes component
is synchronous.
fair enough, well, I'll close this. If you'd be interested in a similar approach that also provides loading banners while the chunks are being loaded, let me know, I've been thinking about making a fork of react-router-loader
or react-proxy-loader
that does that.
This is a good pattern to establish for loading routes asynchronously