hey!
As a newbie, when I started react JS, I don't know where to start today I'm learning how use useState hook in react.
newbie code.
import React, { useState } from "react";
import "./App.css";
function App() {
const [activated, setActivated] = useState(false);
return (
<div className="App">
<h2>React useState Hook</h2>
<p>I am {activated ? "on" : "off"}.</p>
<button type="button"
className="main-button"
onClick={() => setActivated(activated ? false : true)}>
{activated ? "Deactivate Me !" : "Activate Me !"}!</button>
</div>
);
}
export default App;
Top comments (0)