it never says "received new message" even when the...
# help
it never says "received new message" even when there's been an update to the messages
Hello @mudkip! This thread has been automatically created from your message in #843999948717555735 a few seconds ago. We have already mentioned the @User so that they can see your message and help you as soon as possible! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ``...`` menu) and select "Leave Thread" to unsubscribe from future updates. Want to change the title? Use the ``/title`` command! We have solved your problem? Click the button below to archive it.
Have you setup up database replication for the table by turning on operation switches and clicking on table then selecting the table? Do you have RLS on the table?
i dont have rls and no how do i turn on replication?
oh they are all turned on
but is it normal that it shows 0 tables when i have one?
wait i turned it on for the table
@garyaustin is it the strict mode that's causing it to write into my database twice?
how do i prevent it
I don't know what you are referring to
you know how strict mode causes it to run it twice
like in the index.js file
and also if i want to turn on RLS how will it affect the realtime? @garyaustin
Is strict mode something to do with React? If you are getting two console.log for each insert/update then for some reason you have two subscriptions. With RLS on, you have to have a user signed in by the point you subscribe and that user has to meat select RLS policy on that table.
i dont have any sign in though
these policies will work with the code i have now?
i dont need to adjust anything?
Anon should work.
ok good
for some reason whenever i send a message the amount of messages it sends duplicates each time
it sends like 12 messages
Put some console.logs in and see what code might be running multiple times. Look at your network tab and see if you have more than websocket and look in that to see if you get just one event message from the server.
@garyaustin why is my supabase object null?
or at least why could it be null?
@garyaustin sorry i meant undefined
do you know?
You don't show any code setting it up with clientClient, so I could not guess.
Copy code
import { AppContextProvider, useAppContext } from "./context/appContext";
import Chat from './components/Chat.js'
import Login from './components/Login.js'
import './App.css';

function App() {
    const { supabase, user } = useAppContext()

    return (
            <div className="grid h-screen place-items-center">
                {supabase ? <Chat/> : <Login/>}

export default App;
Copy code
import { createContext, useContext, useState, useEffect } from "react";
import { createClient } from "@supabase/supabase-js";

const AppContext = createContext({});

const AppContextProvider = ({ children }) => {
    const supabaseUrl = process.env.REACT_APP_SUPABASE_URL
    const supabaseAnonKey = process.env.REACT_APP_SUPABASE_ANON_KEY
    const supabase = createClient(supabaseUrl, supabaseAnonKey)
there @garyaustin
wait i think i might know
ok nvm
i dont know
console.log supabase right after you set it up and see what you get, if you can. I've not used react in awhile.
in the appcontextprovider?
it's like spamming it infinitely
in the console
1000 messages
ig that's bc it renders it often
and does it instantiate every time you render the app?
Why init the code over and over? If that is the case move it I guess. You should look at some react examples or ask a new question just on that, as I really don't know enough about react particulars anymore.
but that does not explain why it would be null?
It is not null there is it?
Some react thing and contextprovider code issue you likely have. this is the way I normally see it done as an export/import