Skip to content
Advertisement

React firebase doesn’t await

I want to get data from firebase and map it and render a table with it but the firebase function returns data after the page loads.

JavaScript

now if I make a var here let’s say var text= datas and console.log it it will return undefined the feed var is just some dummy text

JavaScript

is there any way to make the page wait for the function to finish the useState ?

Advertisement

Answer

Use the AND operator (&&) which only executes the right operand when the left operand is truthy. It is not necessary to make a variable called dummy.

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement