【问题标题】:How to get selected value onChange of react redux-form react-select如何获取react redux-form react-select的选择值onChange
【发布时间】:2019-02-28 07:44:21
【问题描述】:

我正在使用带有 react-select 的 redux-forms 文件。更改值后,onChange 函数会显示该值。我想检查该值,对于特定值,打开一个对话框让用户确认选择。

import SelectBox from "react-select"

const checkValue= (e) => {
  console.log(e.target.value)
}

const Select= ({...props }) => (
  <Field
    {...props}
    component={SelectBox}
    onChange={e => checkValue(e)}
    items={myItems}
    })}
  />
)

【问题讨论】:

  • 请检查我的答案,它适合你吗?

标签: reactjs redux-form react-select


【解决方案1】:

您可以使用 formValues - 它是一个 redux-form 选择器,可以返回表单中的所有数据。 https://redux-form.com/7.2.3/docs/api/formvalues.md/

但是你应该知道,一旦你将 formValues 选择器应用到一个组件上,它就会对每个字段中的每一个变化做出反应(不仅仅是你需要查看的那些)。这会降低该组件的性能。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多