Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

react useEffect prevent first time

import { useRef, useEffect } from 'react';

export function useFirstRender() {
  const firstRender = useRef(true);

  useEffect(() => {
    firstRender.current = false;
  }, []);

  return firstRender.current;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #react #useEffect #prevent #time
ADD COMMENT
Topic
Name
1+8 =