fjmorant / react-native-nested-listview

Display nested arrays of N levels with this React Native library.
MIT License
196 stars 25 forks source link

Cann't use with state redux #386

Closed nguyenNCphpFox closed 2 years ago

nguyenNCphpFox commented 2 years ago

Describe the bug When I use data from redux get by useSelector and pass to data NestedListView App crash with issue: Error: Invariant failed: A state mutation was detected between dispatches, in the path 'photoBoxes.0.childs' To Reproduce Steps to reproduce the behavior:

  1. const photoBoxes = useSelector(state => state.photoBoxes)
  2. <NestedListView data={photoBoxes} extraData={itemSelected} getChildrenName={()=>'childs'} renderNode={...} />
    1. Update state photoBoxes by action Expected behavior Don't crash Simulator Screen Shot - iPhone 12 - 2022-03-01 at 23 12 34

Screenshots

fjmorant commented 2 years ago

interesting, the library should work fine with redux too, I am going to create an example in the examples project so that we can have a reference and make sure it always works.

Many thx

fjmorant commented 2 years ago

ok, I have created an example for Redux, and it works fine, https://github.com/fjmorant/react-native-nested-listview-examples/blob/master/ReduxExample.tsx, so it would be interesting to know if there un your code there is something else a useEffect maybe??

fjmorant commented 2 years ago

A potential fix of this issue has been amended in version https://github.com/fjmorant/react-native-nested-listview/releases/tag/v0.11.5, please take a look