【问题标题】:Patching AutoComplete In React在 React 中修补 AutoComplete
【发布时间】:2020-12-09 08:35:28
【问题描述】:

我在我的 React 应用程序中修补 AutoComplete 的值时遇到问题。我传递的值只是id,您可以在我的代码框中看到function App({ member_status = 1 })。自动完成需要整个对象来修补它的值。我将如何修补它?

请在下面查看我的代码框

CLICK HERE

代码

function App({ member_status = 1 }) 

initialValues={{
   member_status: member_status
}}

【问题讨论】:

    标签: reactjs ecmascript-6 material-ui formik react-material


    【解决方案1】:

    您需要将初始值设置为选择选项中的对象

    initialValues={{
      member_status: memberStatuses.find((x) => x.id === member_status)
    }}
    

    Demo

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-11-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-25
      • 2016-05-13
      • 2020-08-13
      • 2021-09-03
      • 2020-12-13
      相关资源
      最近更新 更多