mattkrick / meatier

:hamburger: like meteor, but meatier :hamburger:
3.05k stars 173 forks source link

use react-router-loader to cut down on boilerplate needed to load routes asynchronously #159

Closed jedwards1211 closed 8 years ago

jedwards1211 commented 8 years ago

This is a good pattern to establish for loading routes asynchronously

jordanh commented 8 years ago

What's your rationale here? Why go from async to sync?

jordanh commented 8 years ago

Ah, nevermind – I see you're using the loader. It's a little less explicit. Are there other advantages?

jedwards1211 commented 8 years ago

@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

jedwards1211 commented 8 years ago

@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.

mattkrick commented 8 years ago

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.

jedwards1211 commented 8 years ago

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.