-
Notifications
You must be signed in to change notification settings - Fork 524
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
Turbo: data aggregator #2441
base: main
Are you sure you want to change the base?
Turbo: data aggregator #2441
Conversation
…arent/VicChild combination
@scottrippey Do we have additional work to do here? |
@carbonrobot This PoC is complete. The approach worked great, but this only applies to the turbo refactor. I suggest we get this merged, as it vastly improves the turbo codebase. Then we can decide what to do with it along with the rest of turbo. |
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.
Could you update and sync the pnpm merge conflict?
# Conflicts: # pnpm-lock.yaml
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
What
This "data aggregator" approach is to replace the Context-based approach currently used by the Turbo refactor.
The problem
Victory components can be nested inside a parent container:
The parent container, in this example, needs to aggregate all the data from the children, to determine the range, domain, scale, etc.
In the current Turbo refactor, we did this via Context; each child reports its data to the parent. This happens in a
useLayoutEffect
, which suffers from major drawbacks -- primarily that it breaks SSR support.The "Data Aggregator" Approach
This approach is derived from Victory's pre-Turbo behavior. When a parent is rendered, it will actually traverse the
children
and aggregate all data before rendering.This works with SSR, and prevents unneeded rerendering.
This also gives us a chance to normalize the data, and provide a simple API for accessing "normalized" data.