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

useList for Real-time Databae returns object list?

Open vJaun opened this issue 3 years ago • 1 comments

Using the example found here

 snapshots.map((v) => {
               console.log(v.val())
              })

returns { id: { name: "hello" }, id2: {} ... } but when I try to console.log(v.val().name) it returns undefined? and also I thought response would be an array of objects. My database below:

- users
  - uniqueId (used push to generate key)
    - { name: "hello } 

vJaun avatar Feb 18 '22 11:02 vJaun

try to console log v.val()['name'], you get data as json (key,value) so try this console.log(v.val()['name'])

NayanPatil1998 avatar Feb 19 '22 16:02 NayanPatil1998

Closing due to inactivity. Feel free to reopen if this is still an issue

chrisbianca avatar Nov 04 '22 16:11 chrisbianca