Skip to content

Commit 0f3dc3b

Browse files
authored
Address code review comments
1 parent 4460931 commit 0f3dc3b

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

docs/API.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -349,21 +349,25 @@ If `callback` is listed as a 3rd argument, this hook will run asynchronously, an
349349
`cb(err)`
350350

351351
```js
352-
const userIsInAnOrganisation = (nextState, replace, callback) => {
352+
const userIsInAnTeam = (nextState, replace, callback) => {
353353
fetch(...)
354354
.then(response = response.json())
355-
.then(userOrganisations => {
356-
if (userOrganisations.length === 0) {
355+
.then(userTeams => {
356+
if (userTeams.length === 0) {
357357
replace({
358-
pathname: '/users/' + nextState.params.userId + '/organisations/new',
358+
pathname: '/users/' + nextState.params.userId + '/teams/new',
359359
state: { nextPathname: nextState.location.pathname }
360360
})
361361
}
362362
callback();
363363
})
364+
.catch(error => {
365+
// do some async error handling here
366+
callback();
367+
})
364368
}
365369

366-
<Route path="/users/:userId/organisations" onEnter={userIsInAnOrganisation} />
370+
<Route path="/users/:userId/teams" onEnter={userIsInAnTeam} />
367371
```
368372

369373
##### `onChange(prevState, nextState, replace, callback?)`

0 commit comments

Comments
 (0)