React Bits

Updated 2 months ago

Wout Mertens (@wmertens) started discussion #1

3 years ago · 0 comments


Using a function as children isn’t inherently useful.

Function As Children (Edit this file)

Wasteful pattern

A problem with this pattern is that every time you render, you are creating a new children function. To avoid that, you have to create the function outside of the render scope, and then you might as well make a function component that you also provide props to, e.g. <List Component={Item} value={array} props={sharedItemProps}/> would render <Item value={array[i]} {...sharedItemProps}/> for every array item.

Wout Mertens @wmertens commented 3 years ago

That way, you only need to re-render if any of the props change

to join this conversation on GitBook. Already have an account? Sign in to comment

You’re not receiving notifications from this thread.

1 participant