forked from react-navigation/react-navigation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix addListener not registering and firing
Fixed a defect with addListener where it does not register and fire correctly. addListener will only trigger whenever the action is a navigation action. Fixes react-navigation#4670
- Loading branch information
Showing
1 changed file
with
7 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import stackActions from "./routers/StackActions"; | ||
This comment has been minimized.
Sorry, something went wrong. |
||
/* | ||
* This is used to extract one children's worth of events from a stream of navigation action events | ||
* | ||
|
@@ -66,6 +67,12 @@ export default function getChildEventSubscriber(addListener, key) { | |
const upstreamSubscribers = upstreamEvents.map(eventName => | ||
addListener(eventName, payload => { | ||
const { state, lastState, action } = payload; | ||
const navigationActionsList = Object.values(stackActions); | ||
This comment has been minimized.
Sorry, something went wrong.
flyskywhy
|
||
|
||
if (!navigationActionsList.includes(action.type)) { | ||
return; | ||
} | ||
|
||
const lastRoutes = lastState && lastState.routes; | ||
const routes = state && state.routes; | ||
|
||
|
import NavigationActions from "./NavigationActions";