Below is my code snipet. When i receieve my prop and try to useSate, i recieve this infine loop even after following number of solutions.
const App = ({ center }) => {
const position = [-1.29008, 36.81987];
const [mapCenter, setMapCenter] = useState();
useEffect(() => {
if (center && center.length > 0) setMapCenter(center);
else setMapCenter(position);
}, [center, position]);
return (<div> </div>)
}
export default App;
useEffect(() => { // this is only executed once }, [])- Mbanda