Recognized
07/19/2022, 7:20 AMjavascript
useEffect(() => {
let gameListener = supabase
.from("games")
.on("*", (payload) => {
console.log("PAYLOAD", payload.new);
})
.subscribe();
const subscriptions = supabase.getSubscriptions();
console.log("SUBS", subscriptions);
return () => {
supabase.removeSubscription(gameListener);
};
}, []);
here are some potentially useful screenshots to helpgaryaustin
07/19/2022, 12:52 PMRecognized
07/19/2022, 1:35 PMjs
let gameListener = supabase
.from("*")
.on("*", (payload) => {
console.log("PAYLOAD", payload);
})
.subscribe();
when I change the table from "\*" to "games" OR vice versa (changing the table from "games" to "*"), it subscribes properly.
3. I read the thread, but changing strictmode in nextjs doesn't change anythinggaryaustin
07/19/2022, 1:40 PMRecognized
07/19/2022, 1:47 PMRecognized
07/19/2022, 1:49 PMRecognized
07/19/2022, 1:52 PMgaryaustin
07/19/2022, 2:14 PMRecognized
07/19/2022, 2:19 PMRecognized
07/19/2022, 2:21 PMTekey
07/19/2022, 2:36 PMTekey
07/19/2022, 2:37 PMTekey
07/19/2022, 2:39 PMRecognized
07/19/2022, 3:00 PMTekey
07/19/2022, 3:01 PMRecognized
07/19/2022, 3:01 PMTekey
07/19/2022, 3:03 PMRecognized
07/19/2022, 3:03 PMTekey
07/19/2022, 3:05 PMTekey
07/19/2022, 3:06 PMTekey
07/19/2022, 3:06 PMTekey
07/19/2022, 3:06 PMRecognized
07/19/2022, 3:09 PMposts inside your array in the useEffect hook, the hook gets called every time the posts variables changes. if there is nothing inside the array, the useEffect hook is only called when the component is mounted in the vdom. apparently, the subscription to the realtime db should only be done once. so, by removing the dependency inside the array, we make sure that the useEffect hook is only called once.
for strict mode, ``StrictMode renders components twice (on dev but not production) in order to detect any problems with your code and warn you about them (which can be quite useful).``Tekey
07/19/2022, 3:12 PMRecognized
07/19/2022, 3:13 PMgaryaustin
07/19/2022, 3:18 PMTekey
07/19/2022, 3:30 PMTekey
07/19/2022, 4:14 PMTekey
07/19/2022, 4:16 PM