Skip to content

Commit

Permalink
Fix new example
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarry committed Apr 19, 2020
1 parent 137db94 commit 5e44991
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
7 changes: 5 additions & 2 deletions examples/std_web/two_apps/src/lib.rs
Expand Up @@ -92,14 +92,17 @@ impl Component for TwoModels {
TwoModels { }
}

fn mounted(&mut self) -> ShouldRender {
fn rendered(&mut self, first_render: bool) {
if !first_render {
return;
}

let first_app = App::new();
let second_app = App::new();
let to_first = mount_app(".first-app", first_app);
let to_second = mount_app(".second-app", second_app);
to_first.send_message(Msg::SetOpposite(to_second.clone()));
to_second.send_message(Msg::SetOpposite(to_first.clone()));
false
}

fn update(&mut self, _: Self::Message) -> ShouldRender {
Expand Down
13 changes: 8 additions & 5 deletions examples/web_sys/two_apps/src/lib.rs
@@ -1,7 +1,7 @@
#![recursion_limit = "256"]

use yew::html::Scope;
use yew::{html, App, Component, ComponentLink, Html, ShouldRender};
use yew::html::{Scope};

pub struct Model {
link: ComponentLink<Self>,
Expand Down Expand Up @@ -88,17 +88,20 @@ impl Component for TwoModels {
type Properties = ();

fn create(_: Self::Properties, _: ComponentLink<Self>) -> Self {
TwoModels { }
TwoModels {}
}

fn mounted(&mut self) -> ShouldRender {
fn rendered(&mut self, first_render: bool) {
if !first_render {
return;
}

let first_app = App::new();
let second_app = App::new();
let to_first = mount_app(".first-app", first_app);
let to_second = mount_app(".second-app", second_app);
to_first.send_message(Msg::SetOpposite(to_second.clone()));
to_second.send_message(Msg::SetOpposite(to_first.clone()));
false
}

fn update(&mut self, _: Self::Message) -> ShouldRender {
Expand All @@ -117,4 +120,4 @@ impl Component for TwoModels {
</div>
}
}
}
}

0 comments on commit 5e44991

Please sign in to comment.