useToggle
for toggle state
const [on, toggle] = useToggle();
const [on] = useToggle(false);
Description |
---|
Initial state. Default = false |
Description |
---|
Current state value |
Function to update the state |
import React from 'react';
import { useToggle } from '@flywire/react-hooks';
function App() {
const [on, toggle] = useToggle();
return <button onClick={toggle}>{on ? 'ON' : 'OFF'}</button>;
}
export default App;