formik error focus

Solutions on MaxInterview for formik error focus by the best coders in the world

showing results for - "formik error focus"
Yannick
17 Aug 2019
1export default class ScrollToError extends React.Component {
2  componentDidUpdate(prevProps) {
3    if (prevProps.submitCount !== this.props.submitCount && !this.props.isValid) {
4      if (Object.keys(this.props.errors)[0] === this.props.name) {
5        ReactDOM.findDOMNode(this.props.inputRef.current).scrollIntoView({ behavior: 'smooth' });
6      }
7    }
8  }
9
10  render() {
11    return null;
12  }
13}
14