https://github.com/nsaunders/react-router-promises
Adapts react-router hooks to promises instead of callbacks.
https://github.com/nsaunders/react-router-promises
Last synced: about 2 months ago
JSON representation
Adapts react-router hooks to promises instead of callbacks.
- Host: GitHub
- URL: https://github.com/nsaunders/react-router-promises
- Owner: nsaunders
- License: mit
- Created: 2016-09-27T19:17:16.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-05-24T23:11:53.000Z (about 7 years ago)
- Last Synced: 2025-12-12T17:57:18.966Z (6 months ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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);
}
```
```
```
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
});
}
```
```
```