-
Notifications
You must be signed in to change notification settings - Fork 5
Refactor component #24
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
base: clean-up-warnings
Are you sure you want to change the base?
Conversation
eldh
left a comment
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.
Just one comments, otherwise it looks good I think. Maybe @JoelBesada also wants to have a look.
| const tide = { | ||
| keyPaths: this.getKeyPaths(), | ||
| ...this.tide.getComponentProps(), | ||
| } |
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.
I think it makes sense to keep this in the constructor so it's not run each render.
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.
Keep in mind that we need to update it whenever the props change.
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 currently don't, right? They're set as this._componentTide and assumed to be static.
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.
It looks like this section could do with a little bit of a reorganizing as well?
As far as I can tell, the tide prop contains stale keyPaths, which are not used anywhere. So really, the only thing that is interesting in the tide prop, is that actions are passed in.
I also looked into doing a better job of caching getKeyPaths, my guess is that is the most expensive operation per render cycle. I decided not to for readability reasons, wdyt?
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.
I think we want to prioritise performance over readability here. Might be worth doing a benchmark to check what the effects might be.
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.
Sure, check out the benchmarking here: https://gist.github.com/lwakefield/8e8a702dd9b8df7679174e468bad8706
The refactor is a little slower (~3%). Let me see what I can do, but I think we can do better than the existing solution!
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.
Made some tweaks, the variance is pretty wild when profiling, as we are looking at a very specific part. But we are now seeing ~2-5% perf improvement.
JoelBesada
left a comment
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.
Nice
|
@lwakefield is this going live? |
This PR is intended to improve the readability of
TideComponent. I tried to make it "un-opinionated", though I can't vouch for that!Branched from
clean-up-warnings, so if this gets merged, make sure to rebase!