Answers for "is first render react"

0

is first render react

import React, { useEffect, useRef } from 'react';
import { View } from 'react-native';

const App = () => {
  const isFirstRender = useRef<any>(true);

  useEffect(() => {
    if (isFirstRender.current) {
      isFirstRender.current = false;
      console.log('First render')
      return;
    }

    console.log('Other renders...');
  }, []);  
     
  return (
    <View />
  );
};

export default App;
Posted by: Guest on May-15-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language