Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

componentdidmount react hooks

export default function useDidMountHook(callback) {
  const didMount = useRef(null)

  useEffect(() => {
    if (callback && !didMount.current) {
      didMount.current = true
      callback()
    }
  })
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #componentdidmount #react #hooks
ADD COMMENT
Topic
Name
9+5 =