react-context Questions
3
Solved
Let's say we have a context provider set up, along with some initial data property values.
Somewhere along the line, let's say a consumer then modifies those properties.
On page reload, those cha...
Torrance asked 23/11, 2018 at 23:29
2
Solved
Working with Next.js and I am trying to save data inside Context API state after fetching them within getInitialProps, to fix props drilling.
But since getInitialProps is a static method, we can't ...
Conceptacle asked 10/1, 2019 at 11:23
0
In my app, I want to pass the global store of my application to the child components via context. For the sake of an example, I have created 2 child components namely Child1 and Child2, and passing...
Fountain asked 21/12, 2021 at 19:31
3
Solved
I have set a basic sample project that use Context to store the page title, but when I set it the component is not rerendered.
Principal files:
Context.js
import React from 'react'
const Contex...
Dunn asked 15/3, 2020 at 21:16
7
Solved
New to react here and trying to wrap my head round the new Context API (I haven't looked into Redux etc. yet).
Seems I can do much of what I need to do, but I'm going to end up with lots and lots ...
Limestone asked 24/7, 2018 at 17:31
1
Solved
so i'm trying to implement a simple theme switch via react context, and i need to change the value of context(in ThemeProvider.jsx) provider according to a onChange event in another component(Theme...
Lash asked 23/11, 2021 at 7:32
7
Solved
I am using the new useHistory hook of React Router, which came out a few weeks ago. My React-router version is 5.1.2. My React is at version 16.10.1. You can find my code at the bottom.
Yet when I...
Cinchonism asked 3/10, 2019 at 14:12
3
Solved
Hey all im looking for help. im having some trouble with passing data from one child component to another child component using the context api. But i get this typeError instead, i tried a few sear...
Horseflesh asked 3/10, 2021 at 5:28
2
I am workin on a project with React and I need to update react state with react hook when new data is inserted to my database. I am using contextAPI but as far as I am concerned, the way my compone...
Richers asked 24/9, 2021 at 14:43
3
Solved
I had an interview, where the interviewer asked me if redux uses context API internally. Pls provide a detailed description if yes. Thanks
Diadem asked 27/8, 2021 at 7:10
2
Is it safe to use the setter function of a useState hook as a callback ref function? Will this cause trouble with Suspense or other upcoming React changes? If "yes, this is OK", that's cool! If "no...
Zettazeugma asked 9/12, 2019 at 7:3
1
Solved
I'm wondering how I would go about changing the value of a React Context inside a component story in Storybook.
I imagine there is a way to control this via the Story Controls, but there isn't any ...
Southeaster asked 19/7, 2021 at 13:32
4
Solved
I am trying to make authentication for a React JS project but, I am getting the following error:
Rendered fewer hooks than expected. This may be caused by an accidental early return statement.
...
Trudge asked 24/1, 2020 at 15:28
2
I'd like to replicate the behavior of React Context in Nodejs but I'm struggling with it.
In React, by creating only one context, I can provide and consume different values in my components, depend...
Daddy asked 29/6, 2021 at 9:53
2
Solved
I have a react app that uses ContextAPI to manage authentication and I am trying to implement a similar thing in Svelte.
In Authenticate.js I have this:
import React, { useContext, useState, useEff...
Risner asked 23/5, 2021 at 19:39
1
Solved
I found that in the official next.js example, state and dispatch were put info separate context providers.
What was the point of doing so? Does this practice prevent unnecessary re-renders?
export ...
Fragonard asked 24/3, 2021 at 7:46
3
I am trying to create a UserContext to be accessible to all class components in the React app. I am receiving the following error.
ReferenceError: Cannot access 'UserContext' before initialization
...
Bless asked 8/10, 2020 at 5:45
1
I would like to create a wrapper hook around react-query's useQuery hook so that I could catch a 401 error, attempt to refresh access token and if successfully refreshed - invalidate the original q...
Ritual asked 17/2, 2021 at 15:43
4
Solved
I am just curios about if it would be possible to use the Context API inside a Context API. Like for example I would have a Context API for an AppState and want to use that in another Context API w...
Mikelmikell asked 11/10, 2019 at 8:46
1
Solved
First time using the Context API so please bear with me.
I have a local JSON file that I'm trying to fetch from and place the response in the Context API so I can use globally around the app.
Upon ...
Susian asked 25/1, 2021 at 1:36
1
Solved
I am migrating an app from Firebase to AWS Amplify. I want to create a React context which will provide route protection if the user is not logged in.
For example, my Auth.js file:
import React, { ...
Sailcloth asked 12/1, 2021 at 21:49
3
Solved
I am trying to understand how the new react context API works.
In redux, it is possible for a component to have knowledge of dispatch actions without knowing state. This allows updates to redux s...
Chucklehead asked 6/3, 2019 at 4:19
1
I am using a context provider in React to share data across several components. However since a value gets changed from one of my subcomponents, it rerenders all of my other components which partly...
Copyright asked 5/1, 2021 at 2:50
1
Solved
I have several components that require access to the same list of players.
This list of players won't change, but I do not know what component will required it first.
My idea here is that whoever c...
Dipper asked 24/12, 2020 at 14:12
2
Solved
How can we use generics in React.CreateContext?
I had this:
interface Props {
}
export interface SearchContextProps {
dtos: any[];
}
export const SearchContext = React.createContext<SearchC...
Cypher asked 17/3, 2020 at 15:39
© 2022 - 2024 — McMap. All rights reserved.