Next.js Discord

Discord Forum

Class being frozen after being created

Unanswered
Rex posted this in #help-forum
Open in Discord
RexOP
So I got a component, the component doesn't return anything but does have a useEffect to set some stores (Has to be done as a different component and cannot be in the _app file)

I'm using Nextjs v14

The useEffect function is as follows

useEffect(() => {
        const newClient = new Client({
            apiUrl: process.env.PUBLIC_API_URL,
            unAuthed: !token,
            token: token ? token : null,
            version: process.env.PUBLIC_API_VERSION,
            wsUrl: process.env.PUBLIC_API_WS_URL,
            worker: new Worker("/workers/interval.worker.js"),
        })

        setClient(newClient);
    }, [token]);


Though for some reason, the client is being frozen, the clients code doesn't ever freeze itself or the sorts, and testing in other functions it doesn't get frozen or anything

I added

setTimeout(() => {
    console.log(Object.isExtensible(newClient), Object.isFrozen(newClient), Object.isSealed(newClient), newClient)

    const newObjectTest = { test: true };

    console.log(Object.isExtensible(newObjectTest), Object.isFrozen(newObjectTest), Object.isSealed(newObjectTest), newObjectTest)
}, 1500)
for some debugging and only the client is being frozen, the newObject is not being frozen or sealed. Is there any reason for this?

0 Replies