“操作必须是一个普通对象” redux在响应本机时受到重击

时间:2019-06-30 13:10:05

标签: react-native redux redux-thunk

在尝试将一个动作分派到另一个动作时得到此错误。知道我在做什么错吗?

商店

export const setLocation = (coords, maxDistance) => {
    return (dispatch) => {
        return dispatch(setFilteredFacilities(coords, maxDistance))
            .then(() => dispatch({
                type: SET_LOCATION,
                payload: {
                    latitude: coords.latitude,
                    longitude: coords.longitude
                }
            }));
    };
};

动作

<Provider store={store}>
    <App />
</Provider>

index.js

Unresolved reference: adapter   
Unresolved reference: currentItem   
Unresolved reference: addOnPageChangeListener   

1 个答案:

答案 0 :(得分:0)

您正在分派一个函数以及.then中的结果。您无法分派该功能。

export const setLocation = (coords, maxDistance) => 
{ 
     return (dispatch) =>
     {  
         setFilteredFacilities(coords, maxDistance)
         .then(() =>
               dispatch({ type: SET_LOCATION, 
                   payload: { latitude: coords.latitude, longitude: coords.longitude }
                 })
          ); 
     }  
};