Function intuitive::components::experimental::modal::use_modal
source · pub fn use_modal() -> Funcs
Available on crate feature
experimental
only.Expand description
A hook that can control the hiding/showing of a modal.
Like use_state
, calls to use_modal
may only be within a call to
Component::render
. Unlike use_state
, calls to use_modal
may only be within
a component that is a child component of some Modal
. The Funcs
returned by
use_modal
will then refer to the nearest ancestor Modal
. For example, if we
have the following layout:
#[component(MyComponent)]
fn render() {
let modal = use_modal();
render! {
Empty()
}
}
#[component(Root)]
fn render() {
render! {
Modal() { // modal 1
Modal() { // modal 2
Modal() { // modal 3
MyComponent()
}
}
}
}
}
and use_modal
is called within MyComponent
, then it will return a Funcs
struct
that acts on modal 3
. The other two ancestor modals are inaccessible.