useToggleState

This is a simple hook that can be used to keep track of a boolean value and toggle between its two states.

It can be useful to, for example, display or hide the same FocusModal component via multiple triggers, for example, in a table.

Usage

import { useToggleState } from "@medusajs/ui"
const [state, open, close, toggle] = useToggleState()

API Reference


Call Signature

useToggleState(initial: boolean = false)

Returns

ValueTypeDescription
state
StateData
Was this section helpful?

Examples


Entity NameActions
foo
bar
baz
Was this example helpful?