Fix a possible undefined state usage

This commit is contained in:
Lyubomir Marinov 2017-02-10 00:47:55 -06:00
parent c57e713696
commit 183d3c3ca4
1 changed files with 3 additions and 3 deletions

View File

@ -33,10 +33,10 @@ import { MiddlewareRegistry } from '../base/redux';
MiddlewareRegistry.register(store => next => action => { MiddlewareRegistry.register(store => next => action => {
switch (action.type) { switch (action.type) {
case _SET_APP_STATE_LISTENER: { case _SET_APP_STATE_LISTENER: {
const bgState = store.getState()['features/background']; const { appStateListener } = store.getState()['features/background'];
if (bgState.appStateListener) { if (appStateListener) {
AppState.removeEventListener('change', bgState.listener); AppState.removeEventListener('change', appStateListener);
} }
if (action.listener) { if (action.listener) {
AppState.addEventListener('change', action.listener); AppState.addEventListener('change', action.listener);