TypeError:无法读取未定义的属性“ getIn”,不知道出了什么问题

时间:2019-05-31 02:11:40

标签: reactjs

TypeError:无法读取未定义的属性“ getIn” 更新状态有什么问题? 我仍在学习rReact,尝试将状态更新为我的父组件。

我尝试过使用reducer更新状态,这会是什么问题?有什么想法吗?

    (state) => ({
        city: state.input.getIn(['modal','city'])
    }),
    (dispatch) => ({

        // this.props.InputActions.setInput: calling data code
        InputActions: bindActionCreators(inputActions, dispatch)
    })
)(FormContainer);```



modules


const SEARCH = 'input/SEARCH';
const SET_INPUT = 'input/SET_INPUT';
const CHANGE_LOCATION_INPUT = 'input/CHANGE_LOCATION_INPUT';

export const search = createAction(SEARCH, api.getPostList);
export const setInput = createAction(SET_INPUT);
export const changeLocationInput = createAction(CHANGE_LOCATION_INPUT);

const initialState = Map({
        modal: Map({
            city: 36,
            state: 94,
            error: false
        })
});

// //Creating reducer
// export default handleActions({
//     [SET_INPUT]: (state, action) => {
//         return state.set('value', action.payload)
//     }
// })

// reducer
export default handleActions({
    ...pender({
        type: SEARCH,
        onSuccess: (state, action) => {
            const { city } = action.payload.city;
            return state.set('city', city);
        }
    }),
    [CHANGE_LOCATION_INPUT]: (state, action) => {
        const { payload: city } = action;
        return state.setIn(['modal', 'city']);
                    //.set('state', state);
    }
}, initialState)

0 个答案:

没有答案