Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a mounted example #1185

Merged
merged 3 commits into from May 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions yew/src/html/mod.rs
Expand Up @@ -104,6 +104,23 @@ pub trait Component: Sized + 'static {

/// The `rendered` method is called after each time a Component is rendered but
/// before the browser updates the page.
/// ## Examples
/// ```rust
///# use yew::{Html, Component, ComponentLink, html, ShouldRender};
///# struct Model{props: ()};
///# impl Model { fn setup_element(&self) { } }
///# impl Component for Model {
///# type Message = ();type Properties = ();
///# fn create(props: Self::Properties,link: ComponentLink<Self>) -> Self {unimplemented!()}
///# fn update(&mut self,msg: Self::Message) -> bool {unimplemented!()}
///# fn view(&self) -> Html {unimplemented!()}
///# fn change(&mut self, _props: Self::Properties) -> ShouldRender { unimplemented!() }
/// fn rendered(&mut self, first_render: bool) {
/// if first_render {
/// self.setup_element(); // Similar to 'mounted' in other frameworks
/// }
/// }
///# }
fn rendered(&mut self, _first_render: bool) {}

/// The `destroy` method is called right before a Component is unmounted.
Expand Down