如何在渲染道具中使用setFieldValue

时间:2019-11-24 16:51:07

标签: reactjs typescript

我正面临着一次错误。我只显示第一次单击开关之后,什么也没显示。

> index.js:1375 Warning: Cannot update during an existing state
> transition (such as within `render`). Render methods should be a pure
> function of props and state. 
>     in OrgBranchSelection (at Store.tsx:183)
>     in Formik (at Store.tsx:203)
>     in StoreForm (at Store.tsx:95)
>     in Store (created by Router.Consumer)
>     in Router.Consumer (created by Route)
>     in Route (at App.tsx:47)
>     in App (created by Router.Consumer)
>     in Router.Consumer (created by withRouter(App))
>     in withRouter(App) (at src/​index.tsx:13)

导致此问题的代码是:

<OrgBranchSelection
    showCompanyOrBranch={'both'}
    initCompanyKeys={bag.values.orgList}
    initBranchKeys={bag.values.branchList}
    renderBranchKeys={keys => {
        if(bag.values.branchList !== keys) bag.setFieldValue('branchList', keys)
    }}
    renderCompanyKeys={keys => {
        if(bag.values.orgList !== keys) bag.setFieldValue('orgList', keys)
    }}
/>

我想重新设置胶袋值。 任何身体都可以帮忙吗???

0 个答案:

没有答案