TypeError从JoinNavigator启动。
export class JoinNavigator extends React.Component {
render() {
return (
<JoinStackNavigator
onNavigationStateChange={(prevState, currentState) => {
this._getCurrentRouteName(currentState)
}}
/>
);
}
_getCurrentRouteName(navState) {
if (navState.hasOwnProperty('index')) {
this._getCurrentRouteName(navState.routes[navState.index])
} else {
console.log("Current Route Name:", navState.routeName);
let regExp = /^AskStep/;
if(navState.routeName.match(regExp)){
this.props._changeVisibleStatusBar(); //It's located at this.
}
}
}
}
const mapStateToProps = ({app}) => {
return app;
};
const mapDispatchToProps = dispatch => {
return {
_changeVisibleStatusBar: () => {
dispatch(changeVisibleStatusBar(false))
}
};
};
export default connect(mapStateToProps, mapDispatchToProps)(JoinNavigator);
动作。
当我在JoinNavigator上调用该动作时,它可以正常工作。没问题。
import {
APP_STATUS_BAR
} from './types'
export const changeVisibleStatusBar = (val) => {
return {
type: APP_STATUS_BAR,
payload: {hiddenStatusBar: val}
}
};
减速器。
你可以看到&#34; console.log&#34;。
它的作品。
所有数据参数都在React Native Debugger上很好地显示。
import {
APP_STATUS_BAR
} from '../actions/types';
const INITIAL_STATE = {
hiddenStatusBar: false,
isFetching: false,
error: false
};
export default (state = INITIAL_STATE, action) => {
switch (action.type) {
case APP_STATUS_BAR:
console.log(action); //It's works well.
return {
...state,
...action.payload
};
default:
return state;
}
};
显然, - 从JoinNavigator调用Action。 - 它被派遣并通过Action to Reducer传递。 (我看到了console.log)
所以...为什么是TypeError?
TypeError:TypeError:无法读取属性&#39; type&#39;未定义的
This error is located at:
in NavigationContainer (at JoinNavigator.js:60)
in JoinNavigator (created by Connect(JoinNavigator))
in Connect(JoinNavigator) (at SceneView.js:17)
in SceneView (at CardStack.js:385)
in RCTView (at View.js:71)
.....
需要帮助。
谢谢。
答案 0 :(得分:0)
尝试在chrome或Firefox中安装redux dev工具,以检查触发的操作。一些未定义的动作正在调度,但很难知道从哪里开始