New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memoize data derived from useExtensions #4232
Memoize data derived from useExtensions #4232
Conversation
/> | ||
), | ||
})), | ||
[resourcePageExtensions, props.kind, props.kindObj, props.name, props.namespace, props.match], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note, we could also replace props.xxx
with just props
but that isn't 100% correct from hook dependency point of view (since we only use specific parts of the whole props
object in the computation function).
The main reason for not destructuring props
into smaller pieces is to minimize changes.
.filter( | ||
(tab) => | ||
props.obj?.data && | ||
referenceForModel(tab.properties.model) === referenceFor(props.obj.data), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, it would be much safer to compute referenceFor(props.obj.data)
first and not depend on the object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, will do.
few notes:
|
4981231
to
18cae2a
Compare
Agreed, let's do this as a follow-up.
Thanks, removed 😃 |
18cae2a
to
9cb626b
Compare
/retest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about this version?
@suomiy Looks good, will make those changes. |
9cb626b
to
82add1d
Compare
ok! /lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: suomiy, vojtechszocs The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest Please review the full test history for this PR and help us cut down flakes. |
1 similar comment
/retest Please review the full test history for this PR and help us cut down flakes. |
@vojtechszocs: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
/retest Please review the full test history for this PR and help us cut down flakes. |
With #4211 the result value of
useExtensions
hook changes only when necessary, i.e. when the relevantRootState.FLAGS
subset is changed. (For now, the runtime list of extensions is assumed to be immutable, so the only extension-related "change vector" is Console feature flag Redux substate.)This PR applies memoization to data derived from
useExtensions
calls to further avoid unnecessary React component re-renders.