Background
PERF-4 rule states:
[PERF-4] Memoize objects and functions passed as props
-
Search patterns: useMemo, useCallback, and prop passing patterns
-
Condition: Objects and functions passed as props should be properly memoized or simplified to primitive values to prevent unnecessary re-renders.
-
Reasoning: React uses referential equality to determine if props changed. New object/function instances on every render trigger unnecessary re-renders of child components, even when the actual data hasn't changed. Memoization preserves referential stability.
One of the contributors reported that reviewer can misunderstand this rule. Here's an example that was brought: #74424 (comment)
Next steps
In order to determine if rule is correctly understood by reviewer, we could check how it behaves when passed different types of non-memoized props. For example in the code snippet brought above:
- why reviewer flags
dataSet as incorrect while not reporting on inlined style prop
- is it related to the fact the
dataSet does not have any component-level dependencies and could be easily extracted
Background
PERF-4 rule states:
One of the contributors reported that reviewer can misunderstand this rule. Here's an example that was brought: #74424 (comment)
Next steps
In order to determine if rule is correctly understood by reviewer, we could check how it behaves when passed different types of non-memoized props. For example in the code snippet brought above:
dataSetas incorrect while not reporting on inlinedstylepropdataSetdoes not have any component-level dependencies and could be easily extracted