I'm using Redux Forms:
In Parent:
class Parent extends React.Component {
constructor(props) {
super(props);
this.myRef = React.createRef();
}
componentDidMount() {
console.log(this.myRef);
}
render() {
return (
<div>
<CustomField ref={this.ref} />
</div>
)
}
In CustomField:
import { Field } from 'redux-form';
import Child from 'components/Child';
const CustomField = props => {
return <Field {...props} component={Child} type="text" />;
};
I need to manage focus on the Child component from Parent. Normally you would use a forward ref but I'm not sure if this is possible with Redux Forms? The following is erroring and all the props are undefined:
const CustomField = React.forwardRef((props, ref) => {
return <Field {...props} component={() => <Child {...props} ref={ref} />} type="text" />;
});
Message from the console:
Warning: Failed prop type: Invalid prop component supplied to Field.