is first render react code example
Example: 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;