Reactjs why useEffect sometimes runs on every mount/render instead of just first
问题 I have a useEffect in my Routes in App.js <Switch> <Route exact path={['/en', '/fr']} component={HomePage} /> <Route path={['/en/*', '/fr/*']}> <Route path="/:lang/*" component={DefaultLanguage} /> in the same file(App.js) we have the component like so (using react-localize-redux): const DefaultLanguage = withLocalize( ({ activeLanguage, setActiveLanguage, ...props }) => { useEffect(() => { console.log('setting active language'); setActiveLanguage(props.match.params.lang); }, []); return <></