diff --git a/packages/yew/src/context.rs b/packages/yew/src/context.rs index 3e92c828ded..74514002b79 100644 --- a/packages/yew/src/context.rs +++ b/packages/yew/src/context.rs @@ -24,7 +24,6 @@ pub struct ContextProviderProps { #[derive(Debug)] pub struct ContextProvider { context: T, - children: Children, consumers: RefCell>>, } @@ -85,20 +84,15 @@ impl Component for ContextProvider { fn create(ctx: &Context) -> Self { let props = ctx.props(); Self { - children: props.children.clone(), context: props.context.clone(), consumers: RefCell::new(Slab::new()), } } - fn changed(&mut self, ctx: &Context, _old_props: &Self::Properties) -> bool { + fn changed(&mut self, ctx: &Context, old_props: &Self::Properties) -> bool { let props = ctx.props(); - let should_render = if self.children == props.children { - false - } else { - self.children = props.children.clone(); - true - }; + + let should_render = old_props.children != props.children; if self.context != props.context { self.context = props.context.clone(); @@ -108,7 +102,7 @@ impl Component for ContextProvider { should_render } - fn view(&self, _ctx: &Context) -> Html { - html! { <>{ self.children.clone() } } + fn view(&self, ctx: &Context) -> Html { + html! { <>{ ctx.props().children.clone() } } } }