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