react-query-firebase icon indicating copy to clipboard operation
react-query-firebase copied to clipboard

toArray - Operates on all child nodes

Open Justinohallo opened this issue 3 years ago • 0 comments

When using the toArray option from the useDatabaseValue hook, the data returned from the hook is converted to an array at every child node. Is this the expected behavior?

When the root node points to a collection of simple key-value pairs, the toArray method works as expected. However, when introducing JSON it will convert every child node to an array as well.

Working Example

Initial Values

{a:"a", b:"b"},

Result using toArray

Array [ "a", "ab", ],

However, when a is an object rather than a string, the child node is also sorted.

{a:"a", b:{c:"C"},

Array [ "a", Array [ "C", ], ],

Why is it sorting the child node and not just returning the value ?

Justinohallo avatar Feb 08 '22 01:02 Justinohallo