问答

react Provider如何使用,问题详细如下。

作者:admin 2021-04-21 我要评论

我把 antd Modal 封装成了函数调用的方式 interface NewModalType extends ModalType { content: ReactNode}Moadl.show(params: NewModalType) 我再调用时给 con...

在说正事之前,我要推荐一个福利:你还在原价购买阿里云、腾讯云、华为云服务器吗?那太亏啦!来这里,新购、升级、续费都打折,能够为您省60%的钱呢!2核4G企业级云服务器低至69元/年,点击进去看看吧>>>)

我把antd Modal封装成了函数调用的方式

interface NewModalType extends ModalType {
  content: ReactNode
}

Moadl.show(params: NewModalType)

我再调用时给content传入了另一个react组件,结果报错:

Error: could not find react-redux context value; please ensure the component is wrapped in a <Provider>

根据错误提示给show方法中<Modal />包了一层<Provider?store={store}></Provider>

const?store?=?createStore(()?=>?{});

image

现在有一个问题是:ExecutionPlan.tsx文件中的getTemplateDetails方法被调用了,但是dispatch这个请求却没发出去,感觉这行代码没被执行,我在timingPlan
这个model中给getTimingPlanDetails方法打了断点,发现没执行。

求助

###

试试这样呢?

interface NewModalType extends ModalType {
  content: () => ReactNode
}

Moadl.show(params: NewModalType);

// FwModal.show
{params.content} --- > <param.content />

还是有点问题, 这样会更好点?

interface NewModalType<P> extends ModalType {
  Component: React.Component<P, any>,
  props: P
}
// FwModal.show
<param.Component {...param.props} />

版权声明:本文转载自网络,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。本站转载出于传播更多优秀技术知识之目的,如有侵权请联系QQ/微信:153890879删除

相关文章
  • react Provider如何使用,问题详细如下

    react Provider如何使用,问题详细如下

  • vuex4到底怎么优雅的与typescript结合

    vuex4到底怎么优雅的与typescript结合

  • webpack打包ts如何自动生成声明文件

    webpack打包ts如何自动生成声明文件

  • Ant Design Vue 的 Modal 属性 afterCl

    Ant Design Vue 的 Modal 属性 afterCl

腾讯云代理商
海外云服务器