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

@uifabric/foundation withSlots traverses React.Children even if already provided via parent component e.g. StackView #15473

Closed
KevinTCoughlin opened this issue Oct 12, 2020 · 3 comments
Assignees
Labels
Area: Foundation Fluent UI react (v8) Issues about @fluentui/react (v8) Resolution: Soft Close Soft closing inactive issues over a certain period Type: Bug 🐛

Comments

@KevinTCoughlin
Copy link
Member

Follow-up of #15462. withSlots should re-use children without having to recursively traverse the component tree (expensive). There are TODO comments mentioning this inefficiency. It appears that the method signature can be reworked to avoid having the re-flatten the React.Children to an array. See the "blue" and "red" outlined call stacks below.

image

children = React.Children.toArray(children);

Can we re-use ...children: React.ReactNode[] already traversed via map in StackView and passed into withSlots? This would eliminate the red call stack entirely.

React.Children traversal can be a performance bottleneck for wrapper components if the component sub-tree is large.

Environment Information

  • Package version(s): @uifabric/foundation and dependents
  • Browser and OS versions: ALL

Please provide a reproduction of the bug in a codepen:

Profile this page using the browser's performance profiler to observe the performance bug: https://cdpn.io/kevintcoughlin/debug/gOMaYYV.

Priorities and help requested:

Are you willing to submit a PR to fix? No

Requested priority: Normal

Products/sites affected: OneDrive & SharePoint

@paulgildea
Copy link
Member

@KevinTCoughlin Thanks!

@dzearing - FYI

@dzearing
Copy link
Member

dzearing commented Oct 14, 2020

Yup! Talked with Kevin about it a couple days ago. Great find.

We should have a lint rule on referencing Children.count. I'll see if we can add this.

I did a search of Children.count usage in the repo:

image

@khmakoto I see some usage in Card that seems unnecessary. There's also one in StackItem. Can you help take a look at these?

The Text component is being redone in the @fluentui/react-text package, and does not have the reference. But to fast track removing the reference

The LayoutGroup component in the experimental package should be deleted; in fact we should be deleting all of the dusty components we know aren't used in ODSP, and any we do know should be moved out of experiments into their own package (Tile, TileView)

@msft-fluent-ui-bot
Copy link
Collaborator

Because this issue has not had activity for over 150 days, we're automatically closing it for house-keeping purposes.

Still require assistance? Please, create a new issue with up-to date details.

@msft-fluent-ui-bot msft-fluent-ui-bot added the Resolution: Soft Close Soft closing inactive issues over a certain period label May 24, 2021
@microsoft microsoft locked as resolved and limited conversation to collaborators Jun 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Area: Foundation Fluent UI react (v8) Issues about @fluentui/react (v8) Resolution: Soft Close Soft closing inactive issues over a certain period Type: Bug 🐛
Projects
None yet
Development

No branches or pull requests

6 participants