useContext is a React hook for managing global state through the Context API.
Questions tagged [use-context]
586 questions
0
votes
1 answer
Add an element with React, Typescript and useContext
I'm new to Typescript and not very familiar with the useContext hook. Basically, I have two simple components. I would like to add the items from my left component to the list on the right when I click on the button under them. My items have a name…

NiHaoLiHai
- 23
- 1
- 8
0
votes
1 answer
Context updating without being set in React.js
I am trying to set a value to the value of context/state but it is updating the contaxt/state value instead. As you can see below, I am setting newParticipants equal to the array of global.participants, then when I click the button, it takes the…

B_HOP
- 27
- 4
0
votes
2 answers
Pass data back to React useContext
I have a context.js as follows and so far the data is hardcoded (latitude and longitude) as well as initial weather values saved as objects in the same format I will receive from the server. I for now have an input box, this will be changed to…

Dan Wilstrop
- 355
- 1
- 4
- 12
0
votes
0 answers
Having trouble with UseContext with ReactJs, I need to change the state variable in one component and want that updated state in another component
This is my App.js
function App() {
const [patient, setPatient] = useState("1")
return (
…

nnmast
- 31
- 3
0
votes
1 answer
App.tsx didn't receive the context updated with a new state
I want to change with a toggle in navbar which theme the app will apply, I can update normally the context with the consumer and provider of defaultTheme, but my app didn't update this information.
I've console logged some components to see if…

pedroflp
- 15
- 2
0
votes
1 answer
React: Unable to navigate views with router after changing the state of Context (useContext)
I have a simple setup to test the use of the useContext hook, when you want to change the context value in child components.
A simple Context is defined in its own file like such:
import React from 'react'
const DataContext =…

Joachim Bülow
- 115
- 9
0
votes
2 answers
useContext in reactJS with custom hook leading to undefined object
I am trying to setup a context in React to handle user information which will be called once a user has logged in to the system. However, I am having trouble setting the user in the first place.
As it is, the user will enter their login info, and…

Greg
- 35
- 1
- 2
- 6
0
votes
1 answer
paste token using useReducer with useContext and get undefined part 2
yeah i know this is my part 2 problem. You can see the part 1 in paste token in useReducer with useContext in nextjs and get undefined. So in the part 1 my problem was solved and i didn't get undefined anymore but instead i get an empty object on…
0
votes
1 answer
React useContext + TS error: "property does not exist on '{}'"
I have set a context that distributes Firebase auth objects like this:
export function AuthProvider(props: {children: React.ReactNode}) {
const [user, setUser] = useState({uid: ""});
useEffect(() => {
const unsubsribe =…

Faire
- 706
- 1
- 9
- 31
0
votes
0 answers
games.filter is not a function || React hooks component not receiving data
Up till this point, I have been able to fetch my data from MongoDB and view the data in my frontend console in react but games.filter is stopping my component from receiving the data and display them in the browser.
I have tried using…

GODSWILL
- 21
- 1
- 10
0
votes
1 answer
React native) where should i fetch data from server more faster?
I'm beginner of react-native. I'm making music platform Application with my team.
I have a question. For example, when i search data in Screen1.
and i want to show related detailed data in Screen2.
but detailed data is stored in my db. so, i should…

흑수의 세상
- 5
- 2
0
votes
1 answer
Using context API (React.js) to change only a particular key in state object
I am using context API in react for managing state. For this I have created a file AppContext.js where I have created context and Provider:
import { useState, createContext } from "react";
export const AppContext = createContext();
export const…

Tarun Khare
- 1,447
- 6
- 25
- 43
0
votes
2 answers
Trying to use react-admin transform function on
I'm new to react-admin and I am trying to build a custom image gallery input. it should show a modal with images (data is already fetched and stored in the redux) so the user can select one or more images (upon selection an action is dispatched to…

Kayhan Azadi
- 3
- 3
0
votes
0 answers
Using Dispatch Function to Conditionally Render Components
So I've just refactored an app created in react using useContext/useReducer in order to manage the state better. I'm having a great time and have managed to get the dispatch function to work with bits you have to select.
HOWEVER. When it comes to…

Sam Parry
- 1
- 4
0
votes
0 answers
How to structure the data flow of a React Application using useContext, so that I can handle the state of parent component from child components?
I have just finished this blog post tutorial ReactCalendarComponent and now I am trying to separate the long one page component that the tutorial provides into different components.
I am new to React so I start reading post about which is the best…

Federico Rojo
- 1
- 2