Answers for "react useEffect prevent first time"

0

react useEffect prevent first time

import { useRef, useEffect } from 'react';

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

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

  return firstRender.current;
}
Posted by: Guest on April-21-2021
0

react useEffect prevent first time

import { useRef, useEffect } from 'react';

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

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

  return firstRender.current;
}
Posted by: Guest on April-21-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language