using react hooks code example
Example 1: react hooks
const [state, setState] = useState(initialState);
Example 2: react hooks
function ExampleWithManyStates() {
const [age, setAge] = useState(42);
const [fruit, setFruit] = useState('banana');
const [todos, setTodos] = useState([{ text: 'Learn Hooks' }]);
}
Example 3: components react to hooks
import React, { useState } from 'react';
function Example() {
return (
<div>
<p>You clicked {count} times</p>
<button onClick={() => setCount(count + 1)}>
Click me
</button>
</div>
);
}
Example 4: how to use hooks react
const App = () => {
const [students , setStudents] = useState([]);
return (
)
}