Questions tagged [react-state-management]
637 questions
4
votes
2 answers
Rendering arrays using .map that contains state variables - not updating
I have an array that I am rendering on the render() function. Each element in the array is a HTML element that has state variables that I need to display, the HTML are displaying correctly, but the internal state variables do not update even when…

Jose A Ocasio Serra
- 41
- 2
4
votes
2 answers
REACT.JS: How to loop over all NavBar buttons and remove their class and add "active" class to the clicked button
I am trying to make a simple NavBar with React.js. The problem I found myself in is the looping over all nav buttons and remove the "active" className and then add "active" to just that one clicked button.
I managed to make a state that toggles…

Matt Chowski
- 111
- 1
- 2
- 9
4
votes
1 answer
How is it possible that dynamic components overwrite each other's states?
I have created dynamic Room components which are created based on a room object dispatched by Redux.
{
rooms && rooms.map((room, index) => {
const { name, temperature, humidity, timestamp } = room
return (

Leon Kho
- 97
- 2
- 8
4
votes
3 answers
What's the best way to get textbox values on button click in React?
Normally in HTML you do something like this:
I believe this is not the React way to do it.
Another way to do like i did in my app, is not the best way to…

Salomé
- 303
- 1
- 4
- 14
4
votes
1 answer
Refresh React Component after changing data from modal dialog box
I am building a small web application to learn React and exposed to an issue now. My task is to click on a particular city name and go to another component where that name of the city will be displayed.
On that second component, I have one modal…

Purvish Oza
- 255
- 2
- 7
- 14
4
votes
1 answer
flutter bloc pattren Stream Transformer objects causing syntax errors
I am new to Flutter and Dart language. while following along a tutorial I create a validator class which has 2 StreamTransformers, this is being done in an attempt for bloc pattren, where user will type email and password in 2 TextFields and hence…

Muhammad Touseef
- 4,357
- 4
- 31
- 75
3
votes
3 answers
React useEffect vs react-redux useSelector in @redux-toolkit Race
I lately noticed that calling useSelector in a react-redux is a bit delayed.
Now i am using useEffect to check if the state is a certain value. like so:
const user= useSelector(state=>state.user.value);
useEffect(()=>{
if (!user){
…

Shangab
- 39
- 1
- 9
3
votes
0 answers
Data shared between different users and requests in Next.js?
I do not know how to ask this question more formally. I was looking for state management in React while using Next.js, for example redux or react-query. I have seen a lot of comments that say something along the lines:
Be careful to NOT do that…

entropyfeverone
- 1,052
- 2
- 8
- 20
3
votes
4 answers
useReducer: dispatch action, show state in other component and update state when action is dispatched
I have a problem which I can't figure it out. I'm building an ecommerce react app and using useReducer and useContext for state management. Client opens a product, picks number of items and then click button "Add to Cart" which dispatches an action.…

stex
- 33
- 1
- 5
3
votes
2 answers
Is there a proven way to manage a collection of atoms in Recoil?
I'm testing Recoil and I need to manage a list of posts to display in the homepage.
My first idea was to make a big Atom with all the posts, but this seems a bit violent as we can edit posts directly on the homepage.
My second idea was to…

Xiiryo
- 3,021
- 5
- 31
- 48
3
votes
1 answer
React: using state in a passed callback function to a class constructor doesnt use latest version of state
Sorry for the confusing title, but here is what is going on:
In MyComponent, I am setting a count state with the useState React hook.
Once the component mounts (ie. useEffect with no dependencies), I am instantiaitng two MyClass objects with the…

Moe Bazzi
- 85
- 3
3
votes
0 answers
Best Practise listening to Cookie Changed Event in React / NextJs
Disclaimer:
This is for learning purposes and not a real project, if what I am trying to achieve makes no sense, feel free to point that out.
What I want to do:
If the user visits my website, he has to accept cookies.
If he tries to signup, but has…

Leviathan
- 644
- 1
- 15
- 30
3
votes
1 answer
Making API calls out of React Functional Component
I am new to React and I know about the concepts of Functional and Class components aswell as Hooks such as useEffect and useState; hence I am having troubles turning this knowledge into practice, as I am working on the following React component that…

DWA
- 530
- 1
- 5
- 29
3
votes
2 answers
How can I print multiiple text areas when clicking on a button in reactjs
Within my reactjs class component, I want to create a button that opens a new text area everytime I click on it (e.g., when I click 5 times on it, it should open 5 textareas). In the current result, it only opens a textarea ones.
Thus, In a first…

Rainer Winkler
- 485
- 1
- 7
- 20
3
votes
1 answer
Post data through API with RecoilJS
In RecoilJS docs, there is an example how to handle asynchronous data queries, but it's only about get data.
Let say I have a simple state:
const accountState = atom({
key: "accountState",
default: {
id: "",
name: "",
}
});
And a…

Trí Phan
- 1,123
- 2
- 15
- 33