【问题标题】:redux-form and react-select onChange doesn't update redux valueredux-form 和 react-select onChange 不更新 redux 值
【发布时间】:2016-10-26 05:24:01
【问题描述】:

所以我在使用 redux-form 和 react-select 时遇到了问题,这就是我目前所遇到的:

<Field
   name="objective"
   type="text"
   component={prop => <FormSelect {...prop} options={options} />}
   label="Objective"
/>

然后:

const FormSelect = ({ options, label, input: { value, onChange, onBlur } }) =>
  <ControlGroup title={label} styleId={label}>
    <Select
      options={options}
      simpleValue
      onChange={onChange}
      value={value}
      onBlur={() => onBlur(value)}
      id={label}
    />
  </ControlGroup>;

然后选择值没有改变..

我得到一个 redux-form/CHANGE 和一个 action.payloadawareness (这是我要选择的值),但是在另一个 redux-form action redux-form/BLURaction.payload 的 @987654330 之后@。

我已经阅读了一堆关于此的 github 问题,尝试了很多但似乎没有任何工作..

示例:

https://github.com/JedWatson/react-select/issues/1129

https://github.com/erikras/redux-form/issues/82

我也试过了:onBlur={() =&gt; onBlur('awareness')} 并没有改变 select 上的值,即使两个有效载荷的值相同..

【问题讨论】:

  • 如果将console.log(value) 添加到FormSelect 会发生什么,选择的值是否已通过?
  • value是redux-form生成的空字符串

标签: javascript reactjs redux redux-form react-select


【解决方案1】:

我忘记在我的 reducer 中添加 redux-form reducer.. 还是谢谢

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-09-19
    • 1970-01-01
    • 2018-11-11
    • 2020-01-30
    • 1970-01-01
    • 2022-12-21
    • 2018-05-29
    • 1970-01-01
    相关资源
    最近更新 更多