react-tv-space-navigation
react-tv-space-navigation copied to clipboard
Filtering out data causes many errors like "Error: Node with an ID of root_node_515_virtual_603 has already been registered"
Describe the bug Have a virtual grid, which based off some filters is filtering out the data. When I change the filters multiple of these errors show up.
To Reproduce
const [catFilter, setCatFilter] = useState("Todas");
const schedulePrograms = useMemo(() => {
const p = orderBy(data, (p) => p.program?.createdAt, "desc").map(
(m, index) => ({ ...m, index: index }),
);
if (catFilter !== "Todas") {
return p.filter((m) => m.program.genres?.includes(catFilter));
}
return p;
}, [data, catFilter]);
const setOndemandFilter = useCallback((cat: Category) => {
setCatFilter(cat);
}, []);
return (<SpatialNavigationVirtualizedGrid
data={schedulePrograms}
style={{ backgroundColor: "black" }}
renderItem={renderItem}
itemHeight={207 * 1.075}
numberOfColumns={NUMBER_OF_COLUMNS}
numberOfRenderedRows={NUMBER_OF_RENDERED_ROWS}
numberOfRowsVisibleOnScreen={NUMBER_OF_ROWS_VISIBLE_ON_SCREEN}
onEndReachedThresholdRowsNumber={INFINITE_SCROLL_ROW_THRESHOLD}
scrollInterval={150}
/>)
Expected behavior If this is not the right way to filter data a better understanding of how would be great.
Version and OS
- Library version: 3.1.2
- React Native version: 0.73.6
- OS: Android TV
Hi!
Thank you for the issue. Does the error produce bugs, or is it simply annoying in the console?
Thanks :blush:
@pierpo itβs throwing an error in the console. No bug in particular. Havenβt measured to see if there is a performance issue of any kind.
OK, good to know! That's what I thought haha
In the meantime you could patch this line to silence-out the console.error.
https://github.com/bamlab/react-tv-space-navigation/blob/db1defd964120c1c66b89faffc779da6107a7885/packages/lib/src/spatial-navigation/SpatialNavigator.ts#L53
I'll still have a look to see if there's a way to fix this warning in a clean way π
Thanks @pierpo ππ½
Hey @dgocoder, I wonder if the other fix I made with 3.3.0 also fixes this issue? If you can give it another try, I'd appreciate π
It's just a shot in the dark though, it's a similar matter and there was something really broken with the registering logic.
@pierpo hey been under the weather this week but will give it a try this weekend and let you know!
Hey! I think we found the reason of this. We can confirm that besides the warning, this has no impact indeed. We're working on a fix that will remove the error gracefully.
(Oh, and 3.3.0 won't fix it π don't bother to try)
This warning will be solved by this PR :)
https://github.com/bamlab/react-tv-space-navigation/pull/116
Should be fixed with 3.6.0 π