Closed MeryAmun closed 7 months ago
Hi @MeryAmun 👋 thanks for raising this issue.
When the user logs in or out, we typically recommend clearing the local store in case other users login to the same device.
If in your case you can and/or want to leave the data in the local store, please disregard.
In any case, I'm curious how you might be doing things in your app. Can you share some code snippets such as your graphql schema, how you are configuring Amplify and/or DataStore, calling DataStore.query, as well as any error logs?
Another option would be if you could provide specific reproduction steps for us to follow to reproduce the issue internally, or even a small sample app that reproduces the issue.
hello @chrisbonifacio thank you for your prompt response. Here is the code snippet for datastore query
useEffect(() => {
const removeListener = Hub.listen("datastore", async (capsule) => { const { payload: { event, data }, } = capsule;
console.log("DataStore event", event, data);
if (event === "ready") {
const shops = await DataStore.query(Shop, Predicates.ALL);
setShop(shops[0]);
setLoading(false)
}
}); DataStore.start() return () => { removeListener(); }; }, []);
Also I wish to mention that I am using the withAuthenticator HOC
@MeryAmun, can you clarify if you're running DataStore.stop()
or DataStore.clear()
on/before a user logs out? If they are not being called when a user logs out then I don't think a new ready
event is going to be emitted from Hub after calling DataStore.start()
because it has already started, which might cause the issue you're experiencing.
Closing this issue as we have not heard back from you. If you are still experiencing this, please feel free to reply back and provide any information previously requested and we'd be happy to re-open the issue.
Thank you!
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
Authentication, DataStore
Amplify Version
v6
Amplify Categories
auth, storage
Backend
Amplify CLI
Environment information
Describe the bug
Hello everyone , I have a React JS Amplify Web application and when i log in, the datastore.query queries data normally. But when i logout and login again, i must refresh the page before data can be displayed. Please i need help
Expected behavior
I expected that when I log out and log in again, the data from the datastore should display without me having to refresh the page
Reproduction steps
...
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response