-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Closed
Labels
feature-requestUsed to close PRs that haven't gone through/been accepted the Proposal process yetUsed to close PRs that haven't gone through/been accepted the Proposal process yet
Description
This is a little enhancement I'm asking for. Currently, both onEnter
and onChange
have router state passed as an argument. That allows us doing stuff with router location and parameters. However, it is not the case for onLeave
. Is there any particular reason?
Use case example: I'd like to handle socket.io room joining/leaving on the router.
<Route path="/" component={App}>
<Route
path="/chat/:id"
component={Chat}
onEnter={(nextState) => {
joinChat(nextState.params.id);
}}
onChange={(prevState, nextState) => {
leaveChat(prevState.params.id);
joinChat(nextState.params.id);
}}
onLeave={(prevState) => {
leaveChat(prevState.params.id);
}}
/>
</Route>
I know this could be handled by the component itself, but I'm questioning why not passing the previous state to the onLeave
callback, as it might be helpful in some situations.
Metadata
Metadata
Assignees
Labels
feature-requestUsed to close PRs that haven't gone through/been accepted the Proposal process yetUsed to close PRs that haven't gone through/been accepted the Proposal process yet