Questions tagged [react-state-management]

637 questions
2
votes
3 answers

Mutable state update in react

For example, we have a state defined like this which is having some todos and we want to change done of that todo if they are completed this.state = { // store an array of todo objects todos: [ { task: 'do the dishes', done: false, id: 1…
2
votes
1 answer

How to get the state updated of input field of google map api in React app

According to the official docs of google map api, I was trying to implement the autocomplete search input in my React app as per the following: import React, { Component } from 'react'; export class App extends Component { state = { …
2
votes
1 answer

React - share state beetween separated React Apps possible?

I wrote a React-App and now I want to implement some Tab-Navigation. The problem is, my react app is integrated in a Symfony-Project that uses Twig templates. So my React-App lives in templates/dashboard/index.html.twig: {% block content %} …
Slowwie
  • 1,146
  • 2
  • 20
  • 36
2
votes
4 answers

combining useState hook in a react component

I recently started using react hooks a lot. State management seems more intuitive to me when using "React.useState". Anyway, while it's working ok, I know it's starting to look cluttered the more values I am starting to save to state. For example,…
SkyeBoniwell
  • 6,345
  • 12
  • 81
  • 185
2
votes
2 answers

How to maintain state of child components when they are filtered through the parent component?

I am building a small app using create react app to improve my react knowledge but now stuck with state management. The apps maps through JSON data on the parent component and prints 6 "image cards" as child components with an array of "tags" to…
2
votes
2 answers

Firebase - hold temporary data while being sent to cloud firestore

I have a calendar driven by data from firebase. When a user makes an edit, by moving or resizing a task, it will quickly move back to its original position, then the database will update the client, and the new data will be shown on the page. Here…
2
votes
2 answers

Searchable dropdown in semantic-ui-react does not immediately display full list of options retrieved from API

When I try to call an API to fill semantic UI's options, it displays a portion of the options at first and in order to display the full list I have to click outside the dropdown (blur it) first then click inside it again. I have been stuck on this…
2
votes
1 answer

React Bootstrap Dropdown items does not update on state change

Using react-bootstrap to make a dropdown with a list of checkboxes. When I click the checkboxes the toggle event works but component is not re-rendered and the checkbox does not change. Here is the dropdown component: type Props = { …
2
votes
3 answers

react native - how state works with buttons

I am new to react native and have recently implemented state in my code. I currently have 2 buttons: one to open the camera in my app and one to close the camera. What I want to know is this: would there be a way for me to change a button's state…
2
votes
2 answers

State management from parent component using hooks

I'm quite new to Hooks and I am trying to build a small address book. So I have two components: A ContactCard component A ContactsList component I want cards to be removed when the X is clicked. I managed to toggle the deleted prop of my contact,…
2
votes
1 answer

React State filtering with Context

I'm trying to filter the incoming array of state from the context with the id provided in useParams of react-router-dom. basically, the state comes to component and in the component filtering happens: import React, { useContext } from…
2
votes
2 answers

ReactJS HREF Causes State Loss

I have a parent component called EnrollForm with a BrowserRouter that routes to different sub-components which are the pages of my overall EnrollForm. Each time a sub-component page is filled out and next btn is clicked, all form fields are saved…
user4158347
2
votes
4 answers

React setState callback doesn't re-render a quickly toggled state

Let's say I have a piece of logic (e.g. a search bar) and I want to display a spinner during this time. So I have the following code: this.state = { searching: false, } invokeSearch() { this.setState({ searching: true }) const fuse =…
2
votes
1 answer

Filter state doesn't work correctly in React

My Parent component retrieves the checked inputs value from its child component. So I have a function (handleChecked) that takes two parameters : one 'id' and one checked status 'isChecked' : const handleChecked = useCallback(({ id, isChecked }) =>…
GonZo
  • 23
  • 1
  • 6
2
votes
0 answers

Best practice for using React hooks and Context API to update global state and fetch/provide data from multiple endpoints

I am new to React hooks/Context API. I have read the React hook/context docs, and I am still having trouble with the following: My attempts to update global state by multiple consumer components currently causes frequent overwriting of context…