invertase / invertase/tanstack-query-firebase

toArray - Operates on all child nodes

Open
#36 0 comments 0 reactions 0 assignees View on GitHub
react-query-firebase
Dominant language
TypeScript
Stars
462
Forks
69
PR merge metrics
No merged PRs in 30d

Description

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 ?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.