Questions tagged [react-state-management]

637 questions
6
votes
1 answer

React ChartJS prevent new data from being added into state after it's redrawn?

I'm trying to update my chart using react-chartjs-2. I'm using date picker to filter different data and re-render the chart accordingly such as display data today, yesterday, last 7 days etc.. The data is being fetched from my database However, when…
Curious13
  • 329
  • 2
  • 23
6
votes
6 answers

using Material-ui checkboxes with the reactjs and redux

I want to display the selected checkbox items, for which I'm using material-ui checkbox. Right now I'm only able to display the items with checkboxes, but I am not able to display the selected items. I know it is easy but I'm new to reactjs and…
devanya
  • 167
  • 1
  • 1
  • 10
5
votes
1 answer

Fast changing states without Redux

I'm working on a website with fast changing states and many broadcasts, and I'm trying to create my own global state management with hooks and Context. The only solution I've found to avoid useless rendering is to create two context per state, one…
0xChqrles
  • 433
  • 1
  • 5
  • 10
5
votes
4 answers

Confusion between mobx-state-tree and mobx-keystone. When to use which?

Both recommended in the official Mobx page if one wants an opinionated way to using mobx for state management. Based on these(1,2), keystone seems like an improvement of state-tree. Having everything that state-tree has + more. Nowhere I could find…
5
votes
2 answers

how to hide and show loading spinner - Activity Indicator react native, managing props and state

I have created a custom Activity Indicator class and I want to control the hide/show of it from where I use it. Here is what I have done. CustomActivityIndicator.js import React, { Component } from 'react'; import { ActivityIndicator, View,…
4
votes
0 answers

Zustand: One State Split Into Slices or Multiple Stores?

I'm using Zustand for state management. Currently, I have 20 slices. And I'm afraid the number of slices will triple. What would be the best approach, splitting one really large state into slices or creating multiple stores (and splitting each one…
4
votes
1 answer

can I use context API as almost another source of truth in a project that already has Redux?

I'm working on a project utilizes Redux for managing states of the app. As we know, in Redux there is a principle rule called having only one source of truth which simply means there is just a single JS value containing all of the existing states of…
4
votes
1 answer

React Context API consumption and re-rendering using custom useContext hooks

I am new to web development and was trying my luck with React.js. I started exploring the Context API where I realised that re-renders (if mounted)/update happens when a component is subscribed to a context and the value of the context is…
4
votes
2 answers

React Native setState not working (functional component) at all, not even just out of sync

I appreciate anyone taking the time to go through my code and helping me with what's going wrong (printLang() is always printing 'en' or 'es' depending on which value it took on when I refreshed the app)! I'm using Material Dropdown for the first…
4
votes
0 answers

Apollo Client: best practice to initialize cache with default values?

I've searched for a lot of tutorials about local state management with Apollo Client. To initialize the cache with some init values, from this example, I can do it with typePolicies. By defining reactive variables like this: const todosInitialValue…
4
votes
1 answer

how I test useEffect with isLoading state

I want to build test when the isLoading state change the component. I know in the class component there is the way by do setState with enzyme, but I would like to know how I can do it here. const Spacex = () => { const [open, setOpen] =…
4
votes
2 answers

React - Invariant Violation: Maximum update depth exceeded

I have function for set my state from another class, but i got this following error Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number…
Hanif Nr
  • 432
  • 1
  • 5
  • 15
4
votes
1 answer

Replace props with useContext in React Application

Is there any downside to creating a state object in a parent React component and passing data up and down between nested components using useContext? Would that eliminated the need for props all together? Seems like a much easier and logical way…
4
votes
1 answer

State management with useContext and useReducer and fetching data with useEffect

I have a React app that manages its global state with useContext and useReducer. My BookListcomponent needs to fetch books from a server when it mounts. If fetching the books was successful they should be stored into global state. My approach looks…
f1nan
  • 156
  • 10
4
votes
1 answer

How to manage react state for a list of JSX.Elements correctly

I am using react-hooks to manage a list of JSX.Elements. However, once the element changed, trying to delete it will cause unexpected behavior. I had tried using useReducer, remove by index etc, still unexpected updated result…
1
2
3
42 43