Abhi
0
Q:

formik error focus

export default class ScrollToError extends React.Component {
  componentDidUpdate(prevProps) {
    if (prevProps.submitCount !== this.props.submitCount && !this.props.isValid) {
      if (Object.keys(this.props.errors)[0] === this.props.name) {
        ReactDOM.findDOMNode(this.props.inputRef.current).scrollIntoView({ behavior: 'smooth' });
      }
    }
  }

  render() {
    return null;
  }
}
0

Tags

New to Communities?

Join the community