redux-form: A small breaking change in React v15 impacts redux-form compatibility

I’m getting a bunch of uncontrolled input errors: facebook/react#5864, facebook/react#5821.

Here’s a dirty workaround:

const { fields: { field = '' } } = this.props;
if (!field.value) field.value = '';

Update 15.0.0-rc.1 is released. I realize v0.15 is alpha but I figured I’d report it before it turns into a show-stopping bug.

🍺

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 24 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Just to verify that I’m understanding the issue, the problem is that the value prop cannot be undefined?

const value = undefined;
return <input type="text" value={value}/>; // <-------- bad (uncontrolled)
const value = undefined;
return <input type="text" value={value || ''}/>; // <-------- good (controlled)

Is that an accurate summary?

I’m seeing this again in 6.0.0-alpha.8.

Warning:``value``prop on``input``should not be null. Consider using the empty string to clear the component or``undefined``for uncontrolled components.

React v15 support released with redux-form v5.0.0.

I am still seeing this issue on v5.2.5

value changes to null onFocus of the input

null throws

value prop on input should not be null. Consider using the empty string to clear the component or undefined for uncontrolled components.

Looks like empty string is the way to go.

facebook/react@98d3327a5dd325481e1c92c0e68289956778be6b#L408-L418

Correct. Components should not switch from uncontrolled to controlled, or vice versa, where

controlled = props.checked !== undefined || props.value !== undefined