отреагировать usestate
// Initialize useState.
const [stateVar, setStateVar] = useState();
// The useState parameters define the default value of stateVar.
useState(); // stateVar === undefined
useState(true); // stateVar === true
useState('Hamburger'); // stateVar === 'Hamburger'
// setStateVar is a function that sets the value of stateVar.
setStateVar(value);
// stateVar is equal to the value that was set in the setStateVar-function.
stateVar
/*
Example usage - Everytime you run toggleActive, the isActive
variable will toggle between false and true.
*/
const [isActive, setIsActive] = useState(false);
function toggleActive() {
setIsActive(!isActive);
}
9gram panter