TypeScript React error when passing to context object

In my project, I have a context provider that is itself an object with multiple properties: <Provider value={ { scaleNum: scaleNum, // number scaleLet: scaleLet, // string scaleSettings: scaleSettings, // stateful object setScaleSettings: setScaleSettings, // statesetter function scaleModeOptions: scaleModeOptions // string array } }> {children} </Provider> When I try to pass this, I get the… Read More TypeScript React error when passing to context object

React – Persist Data on Page Refresh (useEffect, useContext, useState)

React noob here. I’m trying to use a combination of Context, useState, useEffect, and sessionStorage to build a functioning global data store that persists on page refresh. When a user logins into the app, I fetch an API and then setUserData when I receive the response. That part works great, but I realized if a… Read More React – Persist Data on Page Refresh (useEffect, useContext, useState)

React context doesn't update value when updated

I’m trying to make a simple routing system. Either the user is authenticated or not. I’m trying to use hooks to achieve this but I’m not having the biggest success with it just yet. authProvider.tsx import React, {Dispatch, PropsWithChildren, SetStateAction, useContext, useState} from "react"; import { signInWithEmailAndPassword } from "firebase/auth"; import {ref, child, get} from… Read More React context doesn't update value when updated

Error when using react context – Cannot destructure property

i trying to using Context on my react app but i got error: Uncaught TypeError: Cannot destructure property ‘selected’ of ‘Object(…)(…)’ as it is undefined. in my InputsList file on this line: const { selected, setSelected } = useContext(ParamsContext); ParamsContext: import { createContext } from ‘react’; export const ParamsContext = createContext({ selected: [], setSelected: ()… Read More Error when using react context – Cannot destructure property

How do I get a component to "listen" to changes in global state in a sibling component?

I’m building a wordle clone. I’ve structured it so that the keypad and the letter display grid are two separate components, Keypad.js and Row,js respectively. Project structure is as follows: src -components |-Grid.js |-Keypad.js |-Row.js -App.js -AppContex.js -index.js When a user enters a letter on the keypad, initially I want that letter to appear in… Read More How do I get a component to "listen" to changes in global state in a sibling component?

how to stop re-rendering of child component if parent update the context or state in react js?

how to stop re-rendering of child component if parent update the context or state in react js ? I am already using React.memo still it is re-rendering. this is my child component const Ab = () => { console.log("—ff-ddd"); const pageContext = useContext(PageContext); useEffect(() => { setTimeout(() => { pageContext.updateGlobalMenu({}); }, 5000); }, []); return… Read More how to stop re-rendering of child component if parent update the context or state in react js?