cooperka / react-native-immutable-list-view

:scroll: Drop-in replacement for ListView, FlatList, and VirtualizedList.
MIT License
205 stars 30 forks source link

Sorted Immutable Map Not Rendering Correctly #23

Closed mmoravec closed 7 years ago

mmoravec commented 7 years ago

I have an immutable map that looks like:

data = { ---header1: { ------prop1: ------prop2: ------etc... ---} ---header2: { ------etc... ---} }

I can't figure out how to get the headers to show up in the correct order with this library. i.e.

header1 header1 data header2 header2 data

They are currently displaying

header2 data header1 data

Do I need to set a section ID somewhere?

cooperka commented 7 years ago

Hi @mmoravec, it's possible there's a bug, but I don't think JavaScript makes any guarantees about ordering for objects. You could try using this to preserve order:

Immutable.OrderedMap([[key1, value1], [key2, value2]])

If that doesn't work, please post a working demo app and I can take a look!

P.S. to format code on GitHub and preserve indentation, you can surround your code with triple ticks on the lines above and below (```).

mmoravec commented 7 years ago

Hey @cooperka thanks for the tips, I'll let you know how the OrderedMap works out.

mmoravec commented 7 years ago

OrderedMap works well. Thanks!