dioxus_router/components/
history_provider.rs

1use dioxus_core::{use_hook, Callback, Element};
2use dioxus_core_macro::{component, Props};
3use dioxus_history::{provide_history_context, History};
4
5use std::rc::Rc;
6
7/// A component that provides a [`History`] for all child [`Router`] components. Renderers generally provide a default history automatically.
8#[component]
9#[allow(missing_docs)]
10pub fn HistoryProvider(
11    /// The history to provide to child components.
12    history: Callback<(), Rc<dyn History>>,
13    /// The children to render within the history provider.
14    children: Element,
15) -> Element {
16    use_hook(|| {
17        provide_history_context(history(()));
18    });
19
20    children
21}