Skip to content

Instantly share code, notes, and snippets.

View eugene-yaroslavtsev's full-sized avatar

Eugene Yaroslavtsev eugene-yaroslavtsev

  • Tokyo, Japan
  • 19:54 (UTC +09:00)
View GitHub Profile
import { compose, withHandlers } from 'recompose'
import { animateScroll } from 'react-scroll'
const scrollToFirstError = errors => {
const errorFields = errors
// Using breakable for loop
for (let i = 0; i < errorFields.length; i++) {
const fieldName = `position-${errorFields[i]}`
// Checking if the marker exists in DOM
const elements = document.querySelectorAll(`[name="${fieldName}"]`)