question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RealtimeDB having issues

See original GitHub issue
import 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:closed
  • Created a year ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
rajesh6161commented, Oct 7, 2022

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.

0reactions
rajesh6161commented, Oct 7, 2022

@ganigeorgiev thanks buddy! I got the idea, it works now 🎊

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found