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
DO NOT MERGE: Request for comments: Plan 5a Proof of concept #3852
Conversation
@@ -2312,7 +2250,6 @@ export const generateCategoricalChart = ({ | |||
Scatter: { handler: this.renderGraphicChild }, | |||
Pie: { handler: this.renderGraphicChild }, | |||
Funnel: { handler: this.renderGraphicChild }, | |||
Tooltip: { handler: this.renderCursor, once: true }, |
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.
Tooltip no longer uses the cloning map!
// @ts-expect-error TODO | ||
position: props.position, | ||
}; | ||
setContext(newContext); |
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.
The public Tooltip
will now only gather and cleanup the public props and push to context - nothing more.
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 should scrutinize every effect we add, but I guess optimizations can come later once its working
y: boolean; | ||
}; | ||
|
||
export type ChartContextType = { |
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.
The context might grow quite a bit, we might consider splitting to one context per component.
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'll have to see how re-renders do as well
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.
Here is the actual Tooltip + Cursor rendering. Reads from props (shared global state) and context (public props).
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.
Combining the Tooltip and the Cursor generally seems like a great refactoring. Do you see a way to get this in independent on the conceptual 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.
Yeah so without the conceptual change the component of TooltipWithCursor
will accept merged props from both. There might be slight complications since they are both rendered at different times (not sure why?). I will look into that.
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.
The more I work on the codebase the less I am convinced we can have a clean split between 5a ("Push") and 5b ("Pull"). It might end up as a combination of both, either way. This could be a special case because |
81680d7
to
caf3235
Compare
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 like the direction! We'll have to be careful about how unwieldy that context gets, it could quite literally get as bad as generateCategoricalChart itself lol
// @ts-expect-error TODO | ||
position: props.position, | ||
}; | ||
setContext(newContext); |
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 should scrutinize every effect we add, but I guess optimizations can come later once its working
y: boolean; | ||
}; | ||
|
||
export type ChartContextType = { |
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'll have to see how re-renders do as well
import { isNumber } from '../util/DataUtils'; | ||
import { ContentType } from '../component/Tooltip'; | ||
|
||
type Props = { |
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.
going forward I think we should be specific about how we name prop types, instead of renaming on export (even though in this case this is scoped to the file)
2e1b2b2
to
22b0c6d
Compare
I think tests are basically passing besides snaps? |
There's still couple of tests red. As I'm going through them I'm
discovering small problems. I want to get all tests green to make sure I
didn't miss any roadblock, and then I move on to 5b.
…On Tue, Oct 24, 2023, 08:33 Coltin Kifer ***@***.***> wrote:
I think tests are basically passing besides snaps?
—
Reply to this email directly, view it on GitHub
<#3852 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAIMTCU7LLHF2QM4PN6TKT3YA3PDHAVCNFSM6AAAAAA57EYAJWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZWGA2TOMBVGI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Sounds good! |
22b0c6d
to
41ef4ed
Compare
41ef4ed
to
7b66cfb
Compare
I can't get the latest changes to work. In the name of performance optimization, this PR introduced mutable variables outside of state: HHongSeungWoo@830bd00 and I can't figure out if it's meant to be that way and I should follow that or if that's an oversight. |
Not using the state was an intentional change. Currently, the tooltip is being rerendered by outer components, so there is no need to trigger state change. but you can change it if necessary |
I don't have enough insight to tell if it's necessary or not but I can tell it looks like an oversight. I recommend to add unit tests that show that it is intentional and what unnecessary re-renders does it prevent. Otherwise you can have someone come and go "This is not The React Way(tm)" and change it. |
And a comment too 😬 |
7b66cfb
to
10b554c
Compare
Sibling PR: #3965 |
Declining in favour of #3965 |
## Description Following up from @nikolasrieble's suggestion in #3852 (comment) I am moving towards merging Cursor and Tooltip component. Cursor depends on Tooltip props anyway so it's a natural refactor. Baby steps. First I move the Cursor rendering as-is to its own component. In a followup PR, I will make it read props from Tooltip directly and remove `renderCursor` method from generateCategoricalChart. ## Related Issue #3717 ## Motivation and Context Small step towards breaking down generateCategoricalChart ## How Has This Been Tested? `npm test`, storybooks ## Screenshots (if appropriate): ## Types of changes - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) ## Checklist: - [X] My code follows the code style of this project. - [ ] My change requires a change to the documentation. - [ ] I have updated the documentation accordingly. - [X] I have added tests to cover my changes. - [X] I have added a storybook story or extended an existing story to show my changes - [X] All new and existing tests passed.
So this doesn't pass tests, I don't think it actually renders the Tooltip at all. All the problems are fixable, I am just wondering what do you think about the general direction before I sink the time into fixing them.
In the meantime I would like to use the Pull Request as a vehicle for comments and discussion.
Please focus on:
Please do not yet pay attention to:
any
Description
As described in #3717:
Tooltip
component is now purely a marker. It renders nothing. It only cleans its props, adds some defaults, and pushes everything into a React.ContextgenerateCategoricalChart
no longer needs to search for theTooltip
Element in DOM because it has all its data in the context. It gets some precomputed data and global state and passes it down to a new component:TooltipRenderer
This is grouping all the small individual renders that used to be split in three places before:Tooltip.render
generateCategoricalChart.renderCursor
generateCategoricalChart.renderTooltip
Related Issue
#3823
Motivation and Context
#3717
How Has This Been Tested?
I tested it won't work, please don't merge it yet.
Screenshots (if appropriate):
Types of changes
Checklist: