-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More generic lazy loading #924
Comments
There's an open issue about async loading handlers: #755 I think the idea behind the example is to give each route handler the ability to define its own preRender function. Instead of creating one wrapper per route handler, you should also be able to create a function that accepts the bundle callback (from function createAsyncHandler(bundle) {
return React.createClass({
mixins: [ AsyncElement ],
bundle: bundle,
preRender: function () {
return <div>Loading handler...</div>;
}
});
}
var routes = <Route handler={createAsyncHandler(require('bundle!./app.js'))}>..</Route>; You probably want to adjust the preRender output, or pass that as an argument as well. |
this is super high on our priority list, not sure what we'll end up with, but there will be something. For now I like what @taurose has there. |
Can you guys perhaps shed some light onto this - the initial example is gone and it's hard to decipher the idea from what is in here (or other threads). Is there, somewhere, coherent explanation as to what the idea was? So that we can stop writing horrible workarounds. Thank you. |
Which idea do you mean exactly? You can find the referenced file here. As you can see, lazy loading components worked by wrapping each OP complained about this approach being too tedious, since every single In the next version, it seems like you'll be able to simply define an asynchronous |
@clearly @dnutels check out the "huge-apps" demo on master, and read this: https://rackt.github.io/react-router/tags/v1.0.0-beta2.html#Advanced%20Usage ITS SUPER DUPER AWESOME |
@taurose @ryanflorence Thank you guys. The idea I referred to was lazy loading of routes, especially within webpack. I'll give this a try and report back. |
Is 1.0.0-beta1/2 supposed to work with React 0.13.3? I get an exception running the example from the docs (the very first one). react.js:9259
|
@dnutels not sure if it's related, but I usually see that error when I forget to export my module via |
Nah, installed 1.0.0-beta2. HTML
JavaScript
I had to take ReactRouter for client from node_modules. May be that's the issue. Regardless - bundling it with |
@dnutels In case someone faces the same problem, you require react-router the wrong way: var ReactRouter = require('react-router');
var Router = ReactRouter.Router;
var Route = ReactRouter.Route; |
Given: https://github.com/rackt/react-router/blob/master/examples/partial-app-loading/app.js
I'm new to react-router and I'm trying to find a way to accomplish this type of lazy loading of component views without having to have the Pre{Component1} and Pre{Component2} class types. I'd like to have one PreClass type and I was trying to accomplish instantiating new instances of that class in the routes definition and each instance derive what exact file to lazy load based on the path for that route instance. I've been banging my head against the wall with no luck thus far. ANY pointers on how to accomplish this would be greatly appreciated.
The text was updated successfully, but these errors were encountered: