dioxus-switch 0.1.0

A dioxus libary that gives an alternative to the dioxus-router library which is much simpler to use, recommended for desktop apps only
Documentation
use dioxus_core::{Element, IntoDynNode};
use dioxus_core_macro::{Props, component, rsx};
use dioxus_hooks::{use_context, use_context_provider};
use dioxus_signals::{GlobalSignal, Readable, Signal, Writable};

pub trait Switchable: Default + PartialEq + Clone + 'static {
    fn component(self) -> Element;
}

#[component]
pub fn Switch<T: Switchable + 'static>(#[props(optional)] current: Option<T>) -> Element {
    let context =
        use_context_provider(move || Signal::new(current.unwrap_or_else(|| T::default())));
    rsx! {
        {context.read().clone().component()}
    }
}

pub fn switch<T: Switchable>(to: T) {
    *use_context::<Signal<T>>().write() = to;
}