Skip to content

Instantly share code, notes, and snippets.

@prichodko
Created February 3, 2020 15:34
Show Gist options
  • Save prichodko/3dbe4689ee67af0be2792d9ff62f0d2a to your computer and use it in GitHub Desktop.
Save prichodko/3dbe4689ee67af0be2792d9ff62f0d2a to your computer and use it in GitHub Desktop.
Array of children refs
const Parent = () => {
const refs = React.useRef([])
return React.Children.map(this.props.children, child => {
return React.cloneElement(child, {
ref: ref => refs.current.push(ref)
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment