-
In the React Optimization section of the docs exists a suggestion to postpone dereferencing by using "getter" functions: const MyComponent = ({ person, car }) => (
<>
<GenericNameDisplayer getName={() => person.name} />
<GenericNameDisplayer getName={() => car.model} />
<GenericNameDisplayer getName={() => car.manufacturer.name} />
</>
) This suggestion is unclear to me for two reasons:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Question 1:
I the parent component
I believe it would have the same behaviour as the Question 2:
That looks like a valid concern here depending on your use case. |
Beta Was this translation helpful? Give feedback.
Question 1:
I the parent component
MyComponent
doesn't firegetName
when it renders, thus it won't dehanceperson.name
.I believe it would have the same behaviour as the
getX
function, however you can't re-use the component and use a store.Have a look on Dereference values late section.
Question 2: