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.

Some redux-form properties doesn't change

See original GitHub issue

Well, I wrapped your component into Field by redux-form and trying to get some meta information, like that:

class wrappedPhone extends React.Component {
	/* ... */

	render() {
		console.log(this.props.meta); <------- this one
		const { input } = this.props;
		
		return (
			<Phone
				value={input.value}
				onChange={this.handleOnChange}
			/>
		);
	}
}
<Field
	name="phone"
	component={wrappedPhone}
/>

and while trying to focus/blur/change field there are at least visited and touched meta props doesn’t change.

For simple input it works ok.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
goodwin64commented, Sep 12, 2019

For those who will come to this issue as well as me, the solution is quite simple:

// form.jsx
<form>
  <Field
    component={FieldPhoneNumber}
    name="phoneNumber"
  />
</form>



// FieldPhoneNumber.jsx
export function FieldPhoneNumberBase(props: IProps) {
  const { input, meta, ...restProps } = props;

  return (
    <div>
      <ReactPhoneNumberInput
        {...restProps}
        {...input}            // <--- we spread all input props including onFocus and onBlur
        value={input.value}
        onChange={(phoneNumber) => phoneNumber ? input.onChange(phoneNumber) : input.onChange(null)}
      />
      {
        props.meta.touched && (               // <--- and here we can access all meta props
          <FieldError error={meta.error}/>
        )
      }
    </div>
  );
}
0reactions
catamphetaminecommented, Apr 12, 2018

Maybe it should be written in docs to not doing mistakes. But not sure.

No, it’s purely a redux-form thing. It applies to any React component. The only way is to pass {...this.props} to the component being wrapped.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Form input using Redux Form not updating - Stack Overflow
I changed it from input to something else and it totally broke redux-form SILENTLY. const TextInput = ({ input, <--- DO NOT CHANGE...
Read more >
props - Redux Form
change (field:String, value:any) : Function​​ Changes the value of a field in the Redux store. This is a bound action creator, so it...
Read more >
reduxForm(config:Object)
A callback function that will be called with all the form values any time any of the form values change. onChange will be...
Read more >
Field - Redux Form
A callback that will be called whenever an onChange event is fired from the underlying input. If you call event.preventDefault() , the CHANGE...
Read more >
reduxForm(config:Object)
a function that takes all the form values, the dispatch function, the props given to your component and the current blurred field, and...
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