TitleProvider

Type Alias TitleProvider 

Source
pub type TitleProvider = FunctionComponent<title_provider>;
Expand description

The Title Provider

You should register this title provider like a react context provider.

It accepts two props, a string default_title and a function format_title.

use std::rc::Rc;
use yew::prelude::*;
use yew_side_effect::title::TitleProvider;

pub struct App;

impl Component for App {
    type Message = ();
    type Properties = ();

    fn create(_ctx: &Context<Self>) -> Self {
        Self
    }

    fn view(&self, _ctx: &Context<Self>) -> Html {
        let children = Html::default();

        let format_fn = Rc::new(|m: &str| format!("{} - My Site", m)) as Rc<dyn Fn(&str) -> String>;

        html!{
            <TitleProvider default_title="My Site" format_title={format_fn}>
                {children}
            </TitleProvider>
        }
    }
}

Aliased Typeยง

pub struct TitleProvider { /* private fields */ }