![](/img/trans.png)
[英]Why am I getting Cannot read property 'getCenter' of undefined when trying to access my embed google map?
[英]Why am i still getting cannot read map of undefined?
运行redux sagas并一起做出反应,完全卡住了为什么我仍然遇到未定义的错误。 我设置了一个初始状态,以便.map可以在其上运行,我尝试了null,未定义,空数组-始终是相同的错误。
伙计们,我哪里出问题了?
App.js
{
isFetching ? (
<button disabled>Fetching...</button>
)
:
<div>
<button onClick={onRequest}>Click For API Names</button>
<ul>
{users.map((each, i) => <li key={i}>{each.name}</li>)}
</ul>
</div>
};
...
const mapStateToProps = state => {
return {
isFetching: state.isFetching,
users: state.users,
error: state.error,
};
};
const mapDispatchToProps = dispatch => {
return {
onRequest: () => dispatch({ type: constants.API_REQUEST }),
};
};
reducer.js
const initialState = {
isFetching: false,
users: [{ name: '' }, { name: '' }],
error: null,
};
export const namesReducer = (state = initialState, action) => {
switch(action.type) {
case constants.API_REQUEST:
return {
...state,
isFetching: true,
error: null,
};
case constants.API_SUCCESS:
return {
...state,
isFetching: false,
users: action.payload,
error: null,
};
case constants.API_FAILURE:
return {
...state,
isFetching: false,
users: [''],
error: action.error,
};
default:
return state;
};
}
用户:action.payload
动作有效负载可能不是数组
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.