![](/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.