0

I am trying to get the the data from firebase(realtime database). I refered various videos but I didn't get the proper solution. I don't know where I made a mistake. I share my code and firebase screenshot.

I want to show this firebase data in table form on frontend.

here as screenshot of firebase realtime database.

enter image description here

My Code is:

import React,{useEffect} from 'react'
function TableDataGet() {
 useEffect(() => {
    return () => {
//firebase get table datacode
}})
 return (
<div>
      <div>
        <table>
            <thead>
                <tr>
                    <th>id</th>
                    <th>name</th>
                    <th>nameMarathi</th>
                    <th>srno</th>
                    <th>mobile</th>
                </tr>
            </thead>

            <tbody>
                {
                   DataUser.map((item,id)=>{
                       <div>
                           {item.name}
                       </div>
                   })
                }
            </tbody>
        </table>
        </div>
</div>


 )
}
export default TableDataGet
5
  • I mean, if you Google it there's like 1,000 tutorials on Firebase+React real time data UIs, what specifically do you need help with? Commented Jun 3, 2022 at 5:40
  • Assuming that you didn't take out any code, you've got a ways to go... I'd recommend what Jayce444 said and try to follow a tutorial... and while it doesn't exacly address the issue, if you're trying to decide between the realtime database and firestore, Firestore is newer and recommended (and realtime as well) Best of luck! Commented Jun 3, 2022 at 5:43
  • i just want the code to get the data only in realtime. Commented Jun 3, 2022 at 5:52
  • inside useEffect hook i am writing following code. but its not working, i get only id of data but not get name. Commented Jun 3, 2022 at 5:57
  • useEffect(() => { return () => { const dbRef=ref(db) get(child(dbRef,"userdataRecord")).then((snapshot)=>{ var DataUser=[]; snapshot.forEach(childSnapshot=>{ DataUser.push(childSnapshot.val()) }) TableDataGet(DataUser) }) } }, []) Commented Jun 3, 2022 at 5:57

1 Answer 1

1

here is the query of get data from Firebase Realtime Database.

      let ref = database.ref("/buyers");
      ref.on("value", snapshot => {
      const data = snapshot.val()
      console.log(data)
      })
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.