I am trying to use the React useEffect hook in my code as follows:
function App() {
React.useEffect(() => {
console.log('effect working')
}, [])
return (
<div className="App">
<HomePage/>
</div>
);
}
export default App;
But I'm not getting any output on the console, not even errors. I do not understand where the error lies. PS: I'm using the create-react-app typescript template. I'm willing to provide more information if needed.
if you use this snippet, your code will work
import {useEffect} from 'react';
function App() {
useEffect(() => {
console.log('effect working')
},[])
return (
<div className="App">
<header className="App-header">
</header>
</div>
);
}
export default App;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.