react js useeffect only once code example
Example 1: react run useeffect only once
useEffect(() => {
// Initialization code comes here
}, []);
Example 2: useeffect only on mount
import React, { useEffect } from 'react';
function App() {
useEffect(() => {
// Run! Like go get some data from an API.
}, []);
}