2 Matching Annotations
- Nov 2019
-
stackoverflow.com stackoverflow.com
-
const setRefs = useRef(new Map()).current; const { children } = props; return ( <div> {React.Children.map(children, child => { return React.cloneElement(child, { // v not innerRef ref: node => { console.log('imHere'); return !node ? setRefs.delete(child.key) : setRefs.set(child.key, node)
Illustrates the importance of having unique keys when iterating over children, since that allows them to be used as unique keys in a Map.
-
- Aug 2019
-
github.com github.com