ruby-on-rails - 如何修复“未捕获的 TypeError:调度不是函数”?
问题描述
我在尝试在窗口上执行调度操作时遇到此错误:“未捕获的 TypeError:调度不是函数”。
我仔细检查了语法。
Uncaught TypeError: dispatch is not a function
at Object.eval (spot_actions.js?27ea:12)
at Object.<anonymous> (jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:3412)
at fire (jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:3233)
at Object.fireWith [as resolveWith] (jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:3363)
at done (jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:9841)
at XMLHttpRequest.callback (jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:10312)
export const fetchAllSpots = () => dispatch => (
APIUtil.fetchAllSpots().then(spots =>
dispatch(receiveAllSpots(spots)))
);
const receiveAllSpots = payload => ({
type: RECEIVE_ALL_SPOTS,
payload
});
window.fetchAllSpots = fetchAllSpots();
解决方案
你添加dispatch
到路由器连接?就像是 :
export default connect(mapStateToProps, dispatch => ({
dispatch, ComponentNameHere})) (ComponentNameHere)
推荐阅读
- google-sheets - QUERY(...) 稍微改变日期时间值
- laravel - 使用 nova-media-library 上传图片并使用 nova-page 显示
- sql - SQL:基于另一个表设置条件值,具有 BETWEEN 日期条件
- android-studio - ARcore可以在不触屏的情况下画线吗?
- python - Python中的向量计算
- dji-sdk - DJI Mobile SDK - 调用 sendVirtualStickFlightControlData 时出错
- sql - 关键字“IF”附近的 SQL 语法不正确
- ios - 如何为两个 UIView 中的 UIIMageView 添加触摸处理程序
- android - 颤振中的前台服务不起作用
- javascript - 为什么我可以调用在组件下面声明的函数?