Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

do not trigger useeffect on start

Refer
https://stackoverflow.com/a/71342621/15187131

// Or use useLayoutEffect
const firstUpdate = useRef(true);
  useLayoutEffect(() => {
    if (firstUpdate.current) {
      firstUpdate.current = false;
    } else {
     // do things after first render
  }
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #trigger #useeffect #start
ADD COMMENT
Topic
Name
6+1 =