I'm basing on official example from redux-form-material-ui repo. My code looks like that:
import React from 'react';
import { Field } from 'redux-form';
import { TextField } from 'redux-form-material-ui';
export default class FormTextField extends React.Component {
constructor(props) {
super(props);
}
componentWillUpdate(nextProps) {
const { name, withRef, focus } = nextProps;
if (withRef && focus) {
this.refs[name]
.getRenderedComponent()
.getRenderedComponent()
.focus();
}
}
render() {
const { name, label, errorText, withRef } = this.props;
return (
<Field
name={name}
component={TextField}
hintText={label}
floatingLabelText={label}
errorText={errorText}
ref={name}
withRef={withRef}
/>
);
}
}
I'm passing focus
and withRef
properties ONLY for first field with error. On this field I always get an error: Uncaught (in promise) Error: If you want to access getRenderedComponent(), you must specify a withRef prop to Field(…)
I' able, to see both ref
and withRef
passed to Field
. Then in component with ref="wrappedInstance"
I can still see withRef="true"
. It is not passed deeper.
I would appreciate any thoughts how to solve it.