简体   繁体   English

Redux表单-字段中具有单选类型的自己的值

[英]Redux form - own value in Field with type radio

I want to put some text in to the radio field (with Redux form). 我想在无线电字段中输入一些文本(使用Redux表单)。

I have fields like this: 我有这样的领域:

<Field
  name={some.name1}
  value={'text1'}
  component={renderRadioElement}
  type="radio"
/>

<Field
  name={some.name2}
  value={'text2'}
  component={renderRadioElement}
  type="radio"
/>

...

Everything works correctly until the first value change . 一切正常,直到第一个值更改

If I want to change the value several times: state -> form -> ... -> values -> some does not update values. 如果我想多次更改值: 状态->表单-> ...->值->有些不会更新值。

My question is - how to correctly enter a text value into a radio field? 我的问题是 -如何在无线电字段中正确输入文本值?

If I understood correctly your comment you have a value on your component state where youve decleared the form and you wnat to pass in that value to your field. 如果我正确理解了您的评论,那么您在组件状态中就有一个值,在该状态下,您已经清除了表单,并且您必须将该值传递给字段。 If thats it what you want to do is dispatch the value to the redux-form store. 如果是这样,您要做的就是将值分派到redux-form存储。 To do that in your class you are receiving a prop which is change. 为此,您在课堂上会收到一个改变的道具。 injected by redux-form. 通过redux形式注入。 what you want to do is use that function to set the value 您要做的就是使用该函数来设置值

const { change } = this.props;
change('some.name2', this.state.yourValue)

hope it helps 希望能帮助到你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM