react-tv-space-navigation icon indicating copy to clipboard operation
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"

Open dgocoder opened this issue 1 year ago β€’ 8 comments

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

dgocoder avatar Apr 02 '24 18:04 dgocoder

Hi!

Thank you for the issue. Does the error produce bugs, or is it simply annoying in the console?

Thanks :blush:

pierpo avatar Apr 02 '24 19:04 pierpo

@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.

dgocoder avatar Apr 03 '24 03:04 dgocoder

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 πŸ‘

pierpo avatar Apr 04 '24 08:04 pierpo

Thanks @pierpo πŸ‘πŸ½

dgocoder avatar Apr 05 '24 02:04 dgocoder

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 avatar Apr 11 '24 16:04 pierpo

@pierpo hey been under the weather this week but will give it a try this weekend and let you know!

dgocoder avatar Apr 17 '24 23:04 dgocoder

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)

pierpo avatar Apr 18 '24 16:04 pierpo

This warning will be solved by this PR :)

https://github.com/bamlab/react-tv-space-navigation/pull/116

pierpo avatar Apr 30 '24 12:04 pierpo

Should be fixed with 3.6.0 😊

pierpo avatar May 06 '24 13:05 pierpo