@uifabric/foundation withSlots traverses React.Children even if already provided via parent component e.g. StackView #15473
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 🐛
Follow-up of #15462.
withSlots
should re-usechildren
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 theReact.Children
to an array. See the "blue" and "red" outlined call stacks below.fluentui/packages/foundation/src/slots.tsx
Line 57 in e915a19
Can we re-use
...children: React.ReactNode[]
already traversed viamap
inStackView
and passed intowithSlots
? 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
@uifabric/foundation
and dependentsPlease 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
The text was updated successfully, but these errors were encountered: