File tree Expand file tree Collapse file tree
packages/yew/src/functional/hooks Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -275,8 +275,14 @@ where
275275 let mut val = val. borrow_mut ( ) ;
276276 let next_val = ( * val) . clone ( ) . reduce ( action) ;
277277
278- // Check if the reduce action just returned the same `Rc` again
279- // instead of producing a new one.
278+ // Check if the reduce action just returned the same `Rc` again instead of producing
279+ // a new one.
280+ // NOTE: here we make the assumption that an unchanged address implies that the
281+ // "identity" of the `Rc` is unchanged. This assumption is valid here because we
282+ // still keep the old Rc around. But if we were to instead move the old Rc into
283+ // the `reduce` function, then the address could be reused and the object inside
284+ // the Rc might be different. The `rc_was_reused` variable is thus only meaningful
285+ // as long as we use a `clone` before `reduce`.
280286 let rc_was_reused = Rc :: ptr_eq ( & val, & next_val) ;
281287
282288 let should_render = !rc_was_reused && should_render_fn ( & next_val, & val) ;
You can’t perform that action at this time.
0 commit comments