is first render react

Solutions on MaxInterview for is first render react by the best coders in the world

showing results for - "is first render react"
Angela
27 May 2016
1import React, { useEffect, useRef } from 'react';
2import { View } from 'react-native';
3
4const App = () => {
5  const isFirstRender = useRef<any>(true);
6
7  useEffect(() => {
8    if (isFirstRender.current) {
9      isFirstRender.current = false;
10      console.log('First render')
11      return;
12    }
13
14    console.log('Other renders...');
15  }, []);  
16     
17  return (
18    <View />
19  );
20};
21
22export default App;
23