Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

convert componentDidUpdate into useEffect

const hasMount = useRef(false)

useEffect(() => {
  if (hasMount.current) {
    // code to run when the component is updated
  } else {
    hasMount.current = true
  }
}, /* dependencies */)`
Source by medium.com #
 
PREVIOUS NEXT
Tagged: #convert #componentDidUpdate #useEffect
ADD COMMENT
Topic
Name
5+4 =