victory
victory copied to clipboard
Turbo: data aggregator
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:
<VictoryChart>
<VictoryLine data={data} />
<VictoryBar data={data} />
<VictoryScatter data={data} />
</VictoryChart>
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.
@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.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
victory | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Nov 16, 2023 9:40pm |
⚠️ No Changeset found
Latest commit: d0e93fd8d554c4f487f30755d09c9299cb6d97b9
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR