0.0.8 • Published 6 years ago

react-route-ready v0.0.8

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

react-route-ready

Before hooks for react components using react-router.

Installation

1. Add Middleware to React Router

import { useReactRouteReady } from 'react-route-ready';

// ...

render(<Provider store={store}>
  <Router render={(props) => (applyRouterMiddleware(useReactRouteReady))}>
    {routes}
  </Router>
</Provider>, document.getElementById('root'))

2. Add Decorators to Route components

import LoadingSpinner from './components/LoadingSpinner';

@beforeRouteReadyRender(LoadingSpinner)
@beforeRouteReadyPromise(({params, dispatch, getState})  => {
  return Promise.all([
    dispatch(getAccountSettings()),
    dispatch(getSomePageData()),
  ]);
})
class SomePage extends Component {
  // ...
}

Nested route components will load sequentially and display the component passed into @beforeReadyRender until ready.

0.0.8

6 years ago

0.0.7

7 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago