Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

watch ref.current changes typescript

  const refCallback = useCallback(<T extends HTMLElement>(node: T | null) => {
    if (!node) return
    // do your stuff
  }, [])
  
  // use it like:
  <div ref={(node) => refCallback(node)} />
 
PREVIOUS NEXT
Tagged: #watch #typescript
ADD COMMENT
Topic
Name
7+4 =