All Questions
Tagged with use-context or react-context
3,605 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
-1
votes
2
answers
17
views
How to store data on the client side securely so any component can ask for it [closed]
JS cannot read
XSS safe
Automatically sent
Advice
0
votes
4
replies
80
views
How to access React context for base URL when creating Redux-Toolkit Query API slice?
I am trying to move to RTK Query, but am struggling with one thing - how to access React Context.
I currently am using custom hooks to query a back end. Depending on the environment (dev, uat, prod), ...
2
votes
1
answer
108
views
React - useContext - code executed 2 times in provider
This is my structure about code:
src
App.js
pages
ConfigurationPage.jsx
provider
ConfigurationProvider.jsx
context
ConfigContext.jsx
Explain bug:
The code is executed 2 times in provider.
The ...
0
votes
1
answer
77
views
useContext in TypeScript
import { createContext, useContext, useState, useEffect } from 'react';
import { Appearance } from 'react-native';
import { lightTheme, darkTheme } from '../utility/theme';
type ThemeType = typeof ...
0
votes
0
answers
73
views
Sharing context across apps/packages in Turborepo
My turborepo has several packages, one of which is a ui library that uses some context providers. I export these context providers (Theme, Toast, etc.) so that I can use my UI components in my apps ...
0
votes
0
answers
47
views
Auth context automatically redirect to homepage in case server returns error
if I login with wrong username or password the server (NextJS) will return error message with status code 401, what should happen in this case is that !res.success will be executed and it's indeed ...
0
votes
1
answer
91
views
Context data not updating after navigation to route using same param but different component
I'm building a React app with React Router and a context provider that loads property data based on a propertyId route param.
In my App.jsx, I have the following routes:
<Route path="/edit/:...
0
votes
1
answer
93
views
Does the react context API not hide dependencies?
When I make a component that relies on something like the currently chosen language for example, or maybe a special query function to fetch data, and I provide either of these things via a ...
1
vote
1
answer
73
views
Why do I state variables that are also context variables not render when changed with the useState setter function?
In my Expo React Native application, I have a context variable (trackingAsked) that is also a state variable that I use to display a different opening screen. Everything works fine. On power up, the ...
0
votes
1
answer
54
views
useContext does not show/update the value
I need to save the ID of a field from the settings.tsx view. That value need to be used with other view, like stations.tsx, alarms.tsx, map.tsx.
If later, I need to watch another field, I can change ...
0
votes
1
answer
53
views
Problem using useContext with different views/pages
I am a novice and I need to use a parameter for all view/page of my React Native App.
Scenario: from my setting.tsx view, I can select a field as a preference. From the stations.tsx view, I use ...
1
vote
1
answer
78
views
If a child component consumers a context provider, do its parents also re-render?
Although the docs for context say "React automatically re-renders all the children that use a particular context starting from the provider that receives a different value.", from my testing ...
-1
votes
1
answer
55
views
Why to write .Provider in contexts? [duplicate]
Why do I need to write .Provider?
It works perfectly both with and without it.
Code below works:
import { useState, useEffect, createContext, useContext } from "react";
const ThemeContext = ...
2
votes
1
answer
78
views
setState function not recognized as function
In my React Native app, I'm having a problem where the setState function is not being recognized as a function.
I already inserted the context provider on the App root page and exported the context ...
0
votes
1
answer
78
views
Is posible to create a context in React declaring only one node?
Basically what title says. I want to know if there is any package or other way to declare a context to get data from it (I don ́t need to modify that data) without having to declare a provider, a type ...