RealtimeDB having issues
See original GitHub issueimport PocketBase from 'pocketbase';
import { useEffect, useState } from 'react';
function App() {
const client = new PocketBase('http://127.0.0.1:8090');
const [data, setData] = useState({});
const [title, setTitle] = useState('');
useEffect(() => {
client.realtime.subscribe('sample/36p2v9dpch3p1rf', function (e) {
console.log('realtime', e.record);
setData(e.record);
});
});
const getData = async () => {
const record = await client.records.getOne('sample', '36p2v9dpch3p1rf');
setData(record);
};
const updateData = async () => {
await client.records.update('sample', '36p2v9dpch3p1rf', { title: title });
};
useEffect(() => {
getData();
}, []);
client.realtime.unsubscribe('sample/36p2v9dpch3p1rf');
return (
<div className="App">
<h1>My App</h1>
<p>
{data.title}
{' '}
<b>{data.id}</b>
</p>
<input
type="text"
placeholder="Update Data"
onChange={(e) => setTitle(e.target.value)}
/>
<button onClick={updateData}>Update</button>
</div>
);
}
export default App;
This is my simple code for testing the realtime DB, and I am facing an issue here, that is I can only update the data in realtime once and I need to refresh the page to again update the data. But in case of Dashboard of pocetbase I can update the data and it reflects instantly on the client side. Why is this so?
Issue Analytics
- State:
- Created a year ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Firebase Support | Database issues - Google
Get help quickly with Firebase support. Read our FAQs, Release notes, and guides, ask the community, then get direct support from the Firebase...
Read more >2021 - Firebase Status Dashboard
Summary Date Duration
Downtime with NSS‑253 26 Dec 2018 9 minutes
Downtime with NSS‑232 14 Dec 2018 15 minutes
Issue with Realtime Database 12 Dec 2018...
Read more >Realtime Database Stuck · Issue #1480 · firebase ... - GitHub
When I use firebase realtime database data, I use set to add data, but I can't add it all the time. ... Do...
Read more >Firebase Realtime Database Status. Check if ... - StatusGator
Firebase Realtime Database not working? Check what's wrong with Firebase Realtime Database right now. Receive alerts for Firebase Realtime Database status ...
Read more >javascript - Having problems with firebase realtime-database
When I want to retrieve data from the website it shows 'Client is Offline' error Uncaught (in promise) Error: Error: Client is offline....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I am making a good project using Pocketbase, which can serve as tutorial for other learners, so trying to grasp all of it which is included until now in pocketbase. Btw, its an awesome project that you guys are building.
@ganigeorgiev thanks buddy! I got the idea, it works now 🎊