Skip to content

Commit a913020

Browse files
remove localStorage caching example
1 parent 1c5f1ad commit a913020

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

demos/react-supabase-todolist/src/components/providers/SystemProvider.tsx

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,7 @@ export const SystemProvider = ({ children }: { children: React.ReactNode }) => {
4444
compareBy: (item) => JSON.stringify(item)
4545
}),
4646
watch: {
47-
// This provides instant caching of the query results.
48-
// SQLite calls are asynchronous - therefore on page refresh the placeholder data will be used until the query is resolved.
49-
// This uses localStorage to synchronously display a cached version while loading.
50-
// Note that the TodoListsWidget is wraped by a GuardBySync component, which will prevent rendering until the query is resolved.
51-
// Disable GuardBySync to see the placeholder data in action.
52-
placeholderData: JSON.parse(localStorage.getItem('listscache') ?? '[]') as EnhancedListRecord[],
47+
placeholderData: [],
5348
query: new GetAllQuery<EnhancedListRecord>({
5449
sql: /* sql */ `
5550
SELECT
@@ -71,14 +66,6 @@ export const SystemProvider = ({ children }: { children: React.ReactNode }) => {
7166
}
7267
});
7368

74-
// This updates a cache in order to display results instantly on page load.
75-
listsQuery.registerListener({
76-
onData: (data) => {
77-
// Store the data in localStorage for instant caching
78-
localStorage.setItem('listscache', JSON.stringify(data));
79-
}
80-
});
81-
8269
return {
8370
lists: listsQuery
8471
};

0 commit comments

Comments
 (0)