react-context Questions

0

Working on React app where I have some global state defined with a single reducer currently but would like to introduce multiple reducer as the app is kinda large so would be easier and nicer to or...
Galiot asked 31/3, 2020 at 11:3

1

I'm using lerna to create a monorepo where I'd have a structure like this: root packages application - Our root application components - Just some react components, that are to be used by th...
Aparri asked 28/5, 2019 at 8:42

2

Solved

I have been trying to understand the new React Context API and was playing with it. I just wanted to check a simple case - what all re-renders when data to a Provider is updated. Check this small...
Observation asked 12/6, 2018 at 12:49

1

Solved

When I use React's Context API in my Expo React Native project get this warning: Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a...
Harlin asked 2/3, 2020 at 13:0

1

In my application, I am using React Hooks/Context API. Now I need to assign fetched data from localStorage to initialState.carts / state.carts whenever my Provider component did mount. It would pos...
Hinshaw asked 23/2, 2020 at 16:31

2

Solved

im trying to create an api request with the header value, that is received from a context component. However, as soon as the page component is loaded, it throws an Cannot read property '_id' of nul...

2

Solved

I have a form page structured more or less as follows: <Layout> <Page> <Content> <Input /> <Map /> </Content> </Page> <Button /> </Layou...

1

Solved

Let's say I want to create a UI component for an "accordion" (a set of collapsible panels). The parent component controls the state of which panels are open, while the child panels should be able t...
Tautology asked 30/1, 2020 at 17:25

1

Solved

I have a context named StatusContext like this: export const statusCtxInit = { open: false, toggleOpen() { this.open = !this.open; } }; const StatusContext = React.createContext(statusCtxInit...
Hovey asked 23/1, 2020 at 19:38

2

Solved

I have a requirement in my react application to store API driven data in Context API. Class functions are not there only functional components we are using. I have tried to use await with fetch ca...
Rockribbed asked 29/7, 2019 at 4:23

0

So far I can only find descriptions of how to use the Context API, but not how it works, especially how consumer components are triggered to re-render. Links to source code would be awesome!
Drive asked 26/12, 2019 at 18:21

1

Solved

I would like to add a Loader component to be rendered whenever an API call is being made in React. I want to use react context + hooks instead of redux. As the rules of react hooks say, we should ...
Incomer asked 14/12, 2019 at 14:19

2

Solved

I know that I can wrap HOC with my <Context.Provider> and consume it in all child components. I would like to consume context in two separate components but they are nested somewhere deeply ...
Windpipe asked 20/10, 2019 at 14:31

2

Solved

I need to run some functions (eg. Office UI Fabric React's initializeIcons()) and AXIOS call (eg. retrieve the logged-in user with Context API) only the first time the site is hit, then store the r...
Duong asked 23/9, 2019 at 13:17

1

Solved

I used a structure using React Hooks. It is based on a global Context that contains a combination of reducers (as in the Redux). Also, I widely use custom hooks to separate logic. I have a hook tha...
Accipiter asked 23/9, 2019 at 18:26

2

Solved

Code below demonstrates how I'm trying to implement react's context with react hooks, idea here is that I will be able to easily access context from any child component like this const {authState,...
Mundt asked 16/11, 2018 at 10:25

2

Solved

I am trying to update the context of a React App using data resulted from an API call to a REST API in the back end. The problem is that I can't synchronize the function. I've tried this solution...
Broyles asked 12/9, 2019 at 12:50

2

Solved

I'm trying to port from class component to react hooks with Context API, and I can't figure out what is the specific reason of getting the error. First, my Codes: // contexts/sample.jsx import Re...
Aerodyne asked 4/9, 2019 at 5:40

2

Solved

I've just created a function component which contains the expression const [state, setState] = useState(). Now that I have access to state and setState(), this stateful function component is very s...
Blether asked 25/8, 2019 at 1:20

2

Solved

I'm trying to pass a node from a ref to a context. But because I have no re-render after the first render, the passed node is null. I thought about two variants (but I think they aren't the best): ...
Hollenbeck asked 20/8, 2019 at 11:57

1

Solved

I'm trying to use React Context to manage states for my project, but I can't seem to make it work for my CRA codebase this time while I had successful attempts on other projects. useContext returns...
Sideswipe asked 5/8, 2019 at 15:22

2

I created an app to learn ReactJS. Unfortunately, when I was trying to use context I got 1 error on rendering, but my app compiles well. This is my code: import React, {Component} from 'react'; ...
Singspiel asked 18/7, 2018 at 9:50

1

Solved

I want to save a simple boolean + userID if a user is authenticated and have it accessible via React Context API. Many guides wrapped their root compoennt with the context Provider. To me it seem...
Demodena asked 1/7, 2019 at 1:4

2

Solved

If you have a Redux Application which you'd like to migrate to the new React Context API + hooks (useReducer) how would you replace redux-saga or redux-thunk for handling side effects? Let's take t...
Siglos asked 3/4, 2019 at 17:50

0

Given an app environment where typescript is not an option und React Hooks are used. When using a context with ... const myContext = useContext(MyContext) ...how would one declare the context si...
Nationalize asked 20/6, 2019 at 12:33

© 2022 - 2024 — McMap. All rights reserved.