Top "React-context" questions

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

Access React Context outside of render function

I am developing a new app using the new React Context API instead of Redux, and before, with Redux, when …

reactjs react-context
How to update the Context value in Provider from the Consumer

MyContext.js import React from "react"; const MyContext = React.createContext('test'); export default MyContext; Created A context separate js file …

javascript reactjs react-context
How to update React Context from inside a child component?

I have the language settings in the context as like below class LanguageProvider extends Component { static childContextTypes = { langConfig: PropTypes.object, }; …

javascript reactjs react-context
React Context vs React Redux, when should I use each one?

React 16.3.0 was released and the Context API is not an experimental feature anymore. Dan Abramov (the creator of Redux) wrote …

javascript reactjs redux react-redux react-context
Does new React Context API trigger re-renders?

I have been trying to understand the new React Context API and was playing with it. I just wanted to …

javascript reactjs react-context
Jest mock react context

I need some help understanding how one can test an application using React Context. Here's my sample setup. context.js …

reactjs unit-testing jestjs react-context react-testing-library
_react.default.createContext is not a function when using react-redux

I have a problem when adding components to the entry point, this error immediately pops up here, how to fix …

reactjs react-redux react-context
How to change Context value while using React Hook of useContext

Using the useContext hook with React 16.8+ works well. You can create a component, use the hook, and utilize the context …

javascript reactjs react-hooks react-context
React createContext issue in Typescript?

So I'm having a very weird issue with React Context + Typescript. Working example In the above example, you can see …

reactjs typescript react-hooks react-context
React Context API - persist data on page refresh

Let's say we have a context provider set up, along with some initial data property values. Somewhere along the line, …

reactjs persistence react-context