Skip to content
This repository has been archived by the owner on Apr 6, 2022. It is now read-only.

Latest commit

 

History

History
38 lines (26 loc) · 653 Bytes

README.md

File metadata and controls

38 lines (26 loc) · 653 Bytes

useToggle

useToggle for toggle state

Usage

const [on, toggle] = useToggle();
const [on] = useToggle(false);

Config

Description
Initial state. Default = false

Return pair

Description
Current state value
Function to update the state

Example

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;