首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

对象(...)对于applyMiddleware(thunk.withExtraArgument({ getFirebase,getFirestore }))不是函数错误

对象(...)对于applyMiddleware(thunk.withExtraArgument({ getFirebase,getFirestore }))不是函数错误是由于在使用Redux中间件时出现的常见错误之一。该错误通常发生在使用thunk中间件时,thunk允许我们在Redux中进行异步操作。

在这个错误中,问题出现在applyMiddleware函数的参数中。applyMiddleware函数用于将中间件应用于Redux store。在这种情况下,我们使用了thunk中间件,并传递了一个包含getFirebase和getFirestore的对象作为额外的参数。

然而,这个错误的原因是我们传递的参数不是一个函数。applyMiddleware函数期望中间件是一个函数,而不是一个对象。因此,我们需要将getFirebase和getFirestore封装在一个函数中,以便正确传递给applyMiddleware函数。

修复这个错误的方法是将getFirebase和getFirestore封装在一个函数中,并将其作为参数传递给thunk中间件。例如:

代码语言:txt
复制
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import { getFirebase, getFirestore } from 'redux-firestore';

const store = createStore(
  rootReducer,
  applyMiddleware(thunk.withExtraArgument({ getFirebase, getFirestore }))
);

在这个修复后的代码中,我们将getFirebase和getFirestore封装在一个函数中,并将其作为参数传递给thunk.withExtraArgument函数。然后,我们将thunk中间件与applyMiddleware一起应用于Redux store。

这样修复后,我们就可以正确地使用thunk中间件,并且不会再出现"对象(...)对于applyMiddleware(thunk.withExtraArgument({ getFirebase,getFirestore }))不是函数"的错误。

推荐的腾讯云相关产品和产品介绍链接地址:

  • 云函数(Serverless):https://cloud.tencent.com/product/scf
  • 云数据库 MongoDB 版:https://cloud.tencent.com/product/tcbs-mongodb
  • 云服务器(CVM):https://cloud.tencent.com/product/cvm
  • 云原生应用引擎(TKE):https://cloud.tencent.com/product/tke
  • 云存储(COS):https://cloud.tencent.com/product/cos
  • 人工智能平台(AI):https://cloud.tencent.com/product/ai
  • 物联网通信(IoT):https://cloud.tencent.com/product/iotexplorer
  • 移动推送(信鸽):https://cloud.tencent.com/product/tpns
  • 区块链服务(BCS):https://cloud.tencent.com/product/bcs
  • 腾讯会议:https://cloud.tencent.com/product/tc-meeting
页面内容是否对你有帮助?
有帮助
没帮助

相关·内容

领券