Skip to content

Commit

Permalink
Fix addListener not registering and firing
Browse files Browse the repository at this point in the history
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
shyaniv7 authored Jul 11, 2018
1 parent 69f394b commit 2059422
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/getChildEventSubscriber.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import stackActions from "./routers/StackActions";

This comment has been minimized.

Copy link
@flyskywhy

flyskywhy Apr 29, 2020

import NavigationActions from "./NavigationActions";

/*
* This is used to extract one children's worth of events from a stream of navigation action events
*
Expand Down Expand Up @@ -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.

Copy link
@flyskywhy

flyskywhy Apr 29, 2020

const navigationActionsList = [...Object.values(stackActions), ...Object.values(NavigationActions)];


if (!navigationActionsList.includes(action.type)) {
return;
}

const lastRoutes = lastState && lastState.routes;
const routes = state && state.routes;

Expand Down

0 comments on commit 2059422

Please sign in to comment.