Articles → REACT.JS → Usestate Hooks In React.Js
Usestate Hooks In React.Js
Purpose
Example
import ReactDOM from 'react-dom'
import { useState } from 'react';
const Home = () => {
const [name, setName] = useState('Gyan');
const handleClick = () => {
setName('Gyansangrah');
}
return (
<div>
<p>{name}</p>
<button onClick={handleClick}>Click me</button>
</div>
);
}
ReactDOM.render(<Home />, document.getElementById('root'));
const [name, setName] = useState('Gyan');
Output
Click to Enlarge