[XYChart] <BarGroup> breaks when children are <React.Fragment>s
See original GitHub issueFor reasons to do with accessing data from our redux store, I would like to have my <BarSeries>
inside of a function component.
Unfortunately, the library will try to look at the < DataSetBar>
component as the series it expects, then throw when the entry
’s data
is undefined.
Is there any way to work around this?
Here is my code (abridged):
function DataGroupBar({ dataGroup }) {
return (
<AnimatedBarGroup>
{dataGroup.map((dataSet) => (
<DataSetBar
key={dataSet.rowId}
dataSet={dataSet}
/>
))}
</AnimatedBarGroup>
)
}
function DataSetBar({ dataSet }) {
const { rowId, color } = dataSet
const reportItem = useSelector((state) => state.reports[rowId])
const actualsData = dateRange.map((month) => ({
x: dateParser(month),
y: computeBalance(reportItem),
}))
const budgetsData = dateRange.map((month) => ({
x: dateParser(month),
y: computeBalance(reportItem),
}))
return (
<>
<AnimatedBarSeries
dataKey={`${reportItem.name} Actuals`}
data={actualsData}
{...accessors}
/>
<AnimatedBarSeries
dataKey={`${reportItem.name} Budgets`}
data={budgetsData}
{...accessors}
/>
</>
)
}
Right now, the only way I can see here is to move everything into my <DataGroupBar>
component, forcing me to access all of state.reports
in redux which loses performance as it causes a re-render every time any row in there changes, opposed to accessing just the single row.
I feel like the library should be able to tell that <DataSetBar>
resolves into 2 <AnimatedBarSeries>
and access them directly.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
React.Children.map ambiguous behavior with Fragments
Children.map recursively go through Array children, but does not "penetrate" into Fragments? reactjs.
Read more >Changelog - GitHub
Fragment`, dropping support for `react@^15` - Empty parent `<g>` wrapper around Drag `children` was replaced with a `React.Fragment` which removes a DOM ...
Read more >Rendering child elements in React using Fragments
One of the advantages of using React to render a user interface is that it's easy to break up the UI into components....
Read more >www.allitebooks.com
Binding usually refers to the ability to automatically react and ... It applies its algorithm to all children in its content property when...
Read more >Untitled
In the Display Builder the following changes have been made to the Alert Dialog: The Filters panel has been relocated below the Alerts...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yeah this is because the
<BarGroup />
expects its direct children to be<BarSeries />
. Messing with / traversingchildren
inReact
is a bit gross but seems like we should be able to create a helper function to traverse until aBarSeries
component is found. Will try to look into this this week but don’t have a ton of bandwidth.I am running into this problem when dynamically generating bar series for a bar group and am not sure how to get around it.
Example code