Skip to content

Do not detach child elements if parent element is about to be detached#2420

Merged
voidpumpkin merged 39 commits into
yewstack:masterfrom
futursolo:no-child-detaching-if-parent-detached
Jan 30, 2022
Merged

Do not detach child elements if parent element is about to be detached#2420
voidpumpkin merged 39 commits into
yewstack:masterfrom
futursolo:no-child-detaching-if-parent-detached

Conversation

@futursolo
Copy link
Copy Markdown
Member

Description

This pull request aims to minimise the number of DOM API calls when detaching a large number of elements from the DOM tree by only detaching the upper most parent element.

Checklist

# Conflicts:
#	packages/yew-macro/src/hook/body.rs
#	packages/yew-macro/tests/function_component_attr/hook_location-fail.stderr
#	packages/yew-macro/tests/function_component_attr/hook_location-pass.rs
#	packages/yew/src/functional/hooks/mod.rs
#	packages/yew/src/functional/hooks/use_context.rs
#	packages/yew/src/functional/hooks/use_effect.rs
#	packages/yew/src/functional/hooks/use_memo.rs
#	packages/yew/src/functional/hooks/use_reducer.rs
#	packages/yew/src/functional/hooks/use_ref.rs
#	packages/yew/src/functional/hooks/use_state.rs
#	packages/yew/src/functional/mod.rs
#	website/docs/migration-guides/yew/from-0_19_0-to-0_20_0.mdx
@github-actions
Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit 461cf38):

https://yew-rs-api--pr2420-no-child-detaching-i-ra93dpum.web.app

(expires Sat, 05 Feb 2022 01:30:43 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

@WorldSEnder
Copy link
Copy Markdown
Member

WorldSEnder commented Jan 29, 2022

Almost the same commit as me in de7df26 (not yet in a PR, so feel free to merge this instead).
I think the only place logic differs from mine is in VSuspense where I think we can get away with pretending the detached_parent always detaches.

@futursolo futursolo mentioned this pull request Jan 29, 2022
3 tasks
Copy link
Copy Markdown
Member

@ranile ranile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Just wondering, when is true passed to detach? I see the false being passed almost everywhere.

@ranile ranile requested review from siku2 and voidpumpkin January 30, 2022 10:52
@ranile ranile added A-yew Area: The main yew crate performance labels Jan 30, 2022
@voidpumpkin voidpumpkin merged commit b7b28ba into yewstack:master Jan 30, 2022
@futursolo futursolo deleted the no-child-detaching-if-parent-detached branch March 20, 2022 02:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-yew Area: The main yew crate performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants