DEV Community

RoboRiot
RoboRiot

Posted on

I have two project with the an identical call to the useContext() react function. One project works and the other doesn't

I have to projects where I'm using the useContext() react function to create a user auth context. I'm using the same exact js file in both projects. For some reason in my new project the create context returns a slightly different object than the object in the old projects even though the initialization is identical. This is causing the createContext() function in the new project to return null. The context object in the first project has a calculateChangedBits item which might play a role in I have a theory that this might be due to some sort of react update. Here what is inside the js file. I also added two pictures to show the authUsercontext output for both the old and new project. The old project output is the one with calculateCHangedBits in it.

Old project

New Project

`import { createContext, useContext, Context } from 'react'

const authUserContext = createContext({
authUser: null,
loading: true,
calculateChangedBits: null,
signInWithEmailAndPassword: async () => {},
createUserWithEmailAndPassword: async () => {},
signOut: async () => {}
});

export const useAuth = () => useContext(authUserContext);`

ACI image

ACI.dev: Best Open-Source Composio Alternative (AI Agent Tooling)

100% open-source tool-use platform (backend, dev portal, integration library, SDK/MCP) that connects your AI agents to 600+ tools with multi-tenant auth, granular permissions, and access through direct function calling or a unified MCP server.

Star our GitHub!

Top comments (0)

ACI image

ACI.dev: Fully Open-source AI Agent Tool-Use Infra (Composio Alternative)

100% open-source tool-use platform (backend, dev portal, integration library, SDK/MCP) that connects your AI agents to 600+ tools with multi-tenant auth, granular permissions, and access through direct function calling or a unified MCP server.

Check out our GitHub!