state hook explain code example
Example 1: update state in useState hook
// declare state using useState hook.
// someState is set to someInitialState
const [someState, setSomeState] = useState(someInitialState);
// setSomeState updates the current state
setSomeState(someOtherState);
Example 2: how to use hooks react
const App = () => {
const [students , setStudents] = useState([]);
return (
// put in the jsx code here
)
}