Questions tagged [react-context]

React Context provides a way to pass data through the component tree without having to pass props down manually at every level.

Official React Context Docs

1056 questions
-1
votes
1 answer

React - useContext returns undefined

i'm trying to use React Context to manage authentication, but i can't see the value that return the context in PrivateRoute.js App.js render() { return ( <>
Enzo Zalazar
  • 13
  • 1
  • 5
-1
votes
2 answers

Custom hook not triggering component rerender despite changes in state

Context: I have a custom hook that fetches firestore documents. It watches for document changes, then returns it and the loading state. I'm using this hook in another component. Problem: Changes to the state values returned by the hook (loading and…
kag359six
  • 1,111
  • 1
  • 8
  • 16
-1
votes
3 answers

How to update state when using React Context?

I am using React Context to pass in the state and setState like this const [authContext, setAuthData] = useState({ isAuthenticated: false, userID:"-1", email:"test", name:"test" });
user2775042
  • 479
  • 1
  • 6
  • 19
-1
votes
2 answers

Does the React Context API replace the need for component props?

I've recently upgraded a React 15 project to use React 16.9. Specifically, I've completely replaced redux with the new Context API, pure functional components, and hooks. With the Context API, we also gain the ability for nested child consumers to…
Barry
  • 382
  • 1
  • 3
  • 11
-1
votes
1 answer

Can we use React Context for containers as well?

This is React's explanation for use of Context Context is designed to share data that can be considered “global” for a tree of React components, such as the current authenticated user, theme, or preferred language. While this holds good for…
Edison D'souza
  • 3,887
  • 4
  • 23
  • 36
-2
votes
1 answer

React: Context to pass state between two hierarchies of components

I am developing a website in which I want to be able to access the state information anywhere in the app. I have tried several ways of implementing state but I always get following error message: Element type is invalid: expected a string (for…
1 2 3
70
71