reboottime / React-Develpment

Some notes, thought, articles or source code readings aggregated here about React Web development.
0 stars 0 forks source link

[Advanced React] Components as props - Add flexibility #74

Open reboottime opened 4 months ago

reboottime commented 4 months ago

Component as Props

This article is part of an advanced React series tutorials.

Trade off: Having flexibility but too flexible

Major Content

reboottime commented 4 months ago

The Problem And Solution

image image image image
reboottime commented 4 months ago

View From Performance Perspective

image

Solution: https://react.dev/reference/react/cloneElement#alternatives


 <List
  items={products}
  renderItem={(product, isHighlighted) =>
    <Row
      key={product.id}
      title={product.title}
      isHighlighted={isHighlighted}
    />
  }
/>