-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Logs UI] Move page template to avoid re-renders #151311
[Logs UI] Move page template to avoid re-renders #151311
Conversation
Pinging @elastic/infra-monitoring-ui (Team:Infra Monitoring UI) |
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.
Thanks for opening this 🙏
The new position in the hierarchy looks good to me, it's a much better / clearer home for it.
Thinking aloud here - hasData
and isDataLoading
are hardcoded so it would be nice if we could memoize the component to stop re-renders on context change (for example, adding a filter will cause a re-render of the template). However, due to the way React.memo
works with children
I really can't think of a way to make that work unless I'm missing something 🤔 Any state machine changes are always going to make the two child components need to re-render, as the logStreamPageState
prop will change, and that cancels out the memoization.
@weltenwort Did you have an idea how the memoization might work here? (as you wrote the issue / ACs).
💭 Good question. I don't actually see a way to achieve that and still pass the current state to its child. We could stop doing that, but then we'd loose the type safety of the |
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.
We could stop doing that, but then we'd loose the type safety of the state.matches(), so I'm not too eager for that either.
Yeah, I would agree with that. If performance does become a concern I'm sure there are multiple places we can improve lower in the hierarchy.
LGTM for the change in hierarchy position 👍
@Kerry350 we could actually remove the |
💚 Build Succeeded
Metrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
💔 All backports failed
Manual backportTo create the backport manually run:
Questions ?Please refer to the Backport tool documentation |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
2 similar comments
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
5 similar comments
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
@crespocarlos should we add |
@weltenwort completely missed these comments. Removed the labels. Thanks |
Summary
closes #150624
This PR improves how the page template re-renders, preventing it from doing so when context providers in the hierarchy below it change.
logs_ui.mov
For maintainers
At given moments, the Logs UI URL changes, updating the
logPosition
state. This will re-render the template and its children.