Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

useDatabaseListData() Subscription no happened with no data #497

Unanswered
grojas123 asked this question in Q&A
Discussion options

This is my situation: I am using useDatabaseListData() but the subscription is no active until some data is in the database.
How I can say, "keep watching this subscription until some data show and render the data"

function Showmessages(messagesmetada) {
 if (typeof (messagesmetada.messagesmetada.user) !== 'undefined') { var gameid = messagesmetada.messagesmetada.gameid; }
 var database = useDatabase();
 var querypath = '/messages/' + gameid;
 const messagesRef = ref(database, querypath);
 const { status, data: messages } = useDatabaseListData(messagesRef);
 
 if (typeof (messages) !== 'undefined') 
 { var messagessortedtimestamp=messages.sort((a, b) => { return a.timestamp - b.timestamp; })}
 if (status === 'success') {
 return (<div>
 <table className="table">
 <thead>
 {table_game_chatboard.map(header => {
 return (
 <tr key={header.id}><th>{header.first_col}</th><th>{header.second_col}</th><th>{header.third_col}</th><th>{header.fourth_col}</th>
 </tr>
 )
 })}
 </thead>
 <tbody>
 {messagessortedtimestamp.map(message => {
 var datetime_temp = new Date(message.timestamp);
 var date_temp = datetime_temp.getDate() + "/" + (datetime_temp.getMonth() + 1) + "/" + datetime_temp.getFullYear();
 var time_temp = datetime_temp.getHours() + ":" + datetime_temp.getMinutes() + ":" + datetime_temp.getSeconds();
 return (
 <tr key={message.id} ><td >{message.author}</td><td>{message.text}</td><td>{date_temp}</td><td>{time_temp}</td>
 </tr>
 )
 })}
 </tbody>
 </table>
 </div>
 )
 }
 if (status === 'loading') {
 return <span>Loading...</span>;
 }
 ;
}
You must be logged in to vote

Replies: 1 comment 1 reply

Comment options

Team, I need a light on this, I no sure if this is a case of bad implementation from my side. Now I solved this with a trick in the side of the database with a blank entry, and I simulate and I activate the subscription, and all works nicely. But I need to figure out if I have a solution without this trick.

You must be logged in to vote
1 reply
Comment options

I was no able to solve this , I used a initial dummy data to activate the subcription .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /