3,036 questions
0votes
1answer
60views
Is posible to create a context in React declaring only one node?
Basically what title says. I want to know if there is any package or other way to declare a context to get data from it (I don´t need to modify that data) without having to declare a provider, a type ...
0votes
1answer
34views
State updates causing excessive re-renders in complex React dashboard with nested components [duplicate]
I'm working on a complex analytics dashboard built with React and TypeScript, which involves multiple nested components. I'm using a combination of state management techniques including React Context, ...
1vote
1answer
39views
React context: Should I use the .Provider property?
Looking at the React documentation for Context, the context is used without the .Provider property: import { LevelContext } from './LevelContext.js'; /* LevelContext is defined as export const ...
-1votes
1answer
35views
useContext data is not updated with latest state when changing routes
I created an auth context and set the object to an initial state, then after wrapping the App() with the provider, I am trying to modify the authContext in 1 (Home.js) component and then try to access ...
2votes
2answers
39views
Why App component is not getting context update
I'm trying to set up a context from a custom hook. Here's my code: usePlayerInterface.jsx import { useState } from 'react'; export function usePlayerInterface() { const [userAction, setUserAction] =...
0votes
0answers
18views
react oidc context signinpopup always returns an error that the pop up was closed
I'm using import react-oidc-context to auth with my aws cognito. I'm trying to use the .signinPopup function but whenever the pop up opens I'm getting an error "Popup closed by user" ...
0votes
1answer
35views
Expo-camera error in test flight IOS testing
I've declared a barcode scanner using expo-camera and it seems to work well locally and on android. When testing in test flight on IOS I receive an error when I scan a barcode. I run an api call and ...
0votes
1answer
61views
React get data from children context inside the parent component
I'm trying to set up a form with many rows of data, with each individual items. When I click a button, I want to get all of the data from each children, and submit the form. I'm using context to ...
-1votes
2answers
104views
Why is the state within a react context always the initial state
Original Question I am trying to learn more about the inner workings of React, and here specifically Context Providers so I don't have a use-case in mind, just trying to understand why it works the ...
0votes
0answers
41views
How to rerender only if the correct part of context state changes?
I have setup a state in the context using a reducer const playerStateReducer = ((state: PlayerState, action: PlayerAction) => { switch (action.type) { case "SET_LOCATION": { ...
0votes
0answers
75views
Where is the context state set in React Context?
I've created an app that stores user information in firebase. The main profile page consumes the data via a hook that retrieves the data from firebase/storage. What I'm trying to do in this page is ...
0votes
1answer
39views
React useContext State Updated Not Triggering useEffect [duplicate]
I am attempting to implement the React useContext hook to share the state of a user license. I've found this pattern online but can't seem to get it to work. If the license is not valid, the user is ...
0votes
1answer
47views
Fetch user data once loaded Next.js
I'm attempting to fetch the data from user once the page loads. Although, currently when there is any route changes, it triggers my useEffect and calls the fetch user endpoint which causes my loading ...
0votes
0answers
33views
useContext Returning Empty Object in Vite React Project but Works in CRA
I have a React component in two different projects: Project A: A React project built with react-scripts build (Create React App). Project B: A Vite-based React project using vite build. In both ...
1vote
0answers
41views
How to Share a Provider Across Isolated Components?
I'm working on a framework that allows developers to create extensions for a main app. Extensions can add components to different parts of the app layout, such as the sidebar or workspace, ...