React Router Async Props
Data dependency loading and updating for React Router applications.
WIP
This is a work in progress, we're going to try it out in one of our apps @instructure, see how it goes.
This library assumes Promise
is available as a global.
Usage
// using flux terminology for shared vocabulary, but this library does// not have any opinion about flux var RouteHandler // <-- not the usual RouteHandler! run = ; var Groups = React; var FriendsHandler = React; var AppHandler = React; var routes = <Route handler=AppHandler> <Route name="friends" handler=FriendsHandler/> </Route>; // Same signature as Router.run, except for the 4th argument which is the// aggregate promise of all asyncProp loaders. You can use this to handle// loading errors.var HistoryLocation = ;;
Notes
The error handling from using promises is driving me nuts, so expect the
load
hook to send a callback instead of ask for a promise in the near
future, but promises make waiting on all the load hooks really trivial.
I'd also like the onChange
to be smarter and not cause a rerender from
the top, but only on the route handler that has changed data.
Project
npm installnpm run examples