Akhilesh Gupta
Posted on October 10, 2020
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;
💖 💪 🙅 🚩
Akhilesh Gupta
Posted on October 10, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.