1.0.4 • Published 8 years ago

react-router-promises v1.0.4

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

react-router-promises

Adapts react-router hooks to promises instead of callbacks.

Instead of this:

function loadUsersIntoStore(nextState) {
  return new Promise((resolve, reject) => {
    // fetch user listing and add it to the data store
  });
}

function loadUsersOnEnter(nextState, replace, callback) {
  loadUsersIntoStore(nextState).then(callback);
}

function loadUsersOnChange(prevState, nextState, replace, callback) {
  loadUsersIntoStore(nextState).then(callback);
}

// ...

<Route path="/users" component={UserListing} onEnter={loadUsersOnEnter} onChange={loadUsersOnChange} />

This library will allow you to do this:

import { enter, change } from 'react-router-promises';

function loadUsersIntoStore(nextState) {
  return new Promise((resolve, reject) => {
    // fetch user listing and add it to the data store
  });
}

// ...

<Route path="/users" component={UserListing} onEnter={enter(loadUsersIntoStore)} onChange={change(loadUsersIntoStore)} />
1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago