question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React 15.6.0 + Redux-form has broken radio buttons

See original GitHub issue

What is the current behavior?

A component that demonstrates it:

const dummy = () => (
  <div>
    <fieldset>
      <Field name="foo" component="input" type="radio" value="a" />
      <Field name="foo" component="input" type="radio" value="b" />
      <Field name="foo" component="input" type="radio" value="c" />
      <Field name="foo" component="input" type="radio" value="d" />
    </fieldset>
  </div>
);

const decoratedDummy = reduxForm({
  form: 'dummy',
})(dummy);

Package.json versions:

"react": "15.6.0",
"redux-form": "6.8.0"

I’ve verified that redux-form version doesn’t matter, and that 15.5.4 works but 15.6.0 doesn’t for react. Perhaps it’s related to facebook/react#8575 ?

What happens in the broken case is that the blur and focus events fire, but the change event never fires. I’m not familiar enough with either the React or Redux-form internals to understand what isn’t working.

This behavior could have been what was seen in #2526 as well.

What is the expected behavior?

Being able to select the radio button

Sandbox Link

https://codesandbox.io/s/M8lXj4vRR

Oddly, I wasn’t able to reproduce this in the sandbox. Is there something about Babel or Webpack that could be screwing things up?

What’s your environment?

Browsers: both firefox and chrome Redux-form version: 6.8.0 React version: 15.6.0 Babel core version: 6.17.0 Webpack version: 2.3.3 Node version: 6.7.0

Other information

I’m kind of at a loss for what other information could be pertinent/useful. In the meantime we’ll downgrade to React 15.5.4 and keep running, but this struck me as very odd.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:22
  • Comments:30 (4 by maintainers)

github_iconTop GitHub Comments

11reactions
ggregoirecommented, Aug 22, 2018

Just wasted 1 hour on this: if you pass a number as value, it is not automatically converted to string and it breaks the behavior of the input radio. (The value is correctly set in the reduxform store, but the input never appears selected)

So you need to convert it to string by yourself:

<Field
  name="user"
  component="input"
  type="radio"
  value={user.id.toString()}
/>

Note that passing a number as value to a React input radio works. I guess that’s what confused me.

Hope it can help!

5reactions
lothisoftcommented, Jul 11, 2017

I experienced the same issues as well.

Sandbox Link

https://codesandbox.io/s/G6zR5o3P8

The radio buttons can be selected but the onChange event handler only fires once for each radio button.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React 15.6.0 + Redux-form has broken radio buttons #3087
React 15.6.0 + Redux-form has broken radio buttons #3087 ... What happens in the broken case is that the blur and focus events...
Read more >
Redux Form, Radio Button Fields, how to support variable ...
You can't select an option - the form is broken. What's strange is if I update: value={jobTitle.id} to value="anything" then the radio buttons...
Read more >
Redux Form - The Radio Button onChange handler is called ...
Forked FromRedux Form - Radio Button onChange handler fires only once; Environmentcreate-react-app. Files. RadioButton.js. RadioButtonContainer.js.
Read more >
How to open a modal on click of radio button using reactjs
I have radio button made using reactjs, on click of radio button I want to open a modal using reactjs. New to react....
Read more >
FormSection - Redux Form
The FormSection component makes it easy to split forms into smaller components that are reusable across multiple forms. It does this by prefixing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found