Questions tagged [redux-store]

98 questions
543
votes
33 answers

How to reset the state of a Redux store?

I am using Redux for state management. How do I reset the store to its initial state? For example, let’s say I have two user accounts (u1 and u2). Imagine the following sequence of events: User u1 logs into the app and does something, so we cache…
xyz
  • 5,435
  • 3
  • 9
  • 6
14
votes
2 answers

Load redux store initial state in Detox Testing

Problem We have a quite complex application and we don't want in each test case to go through the whole process to get to specific screen to test it, alternatively we just want to jump to specific one with some state stored in redux store. What…
AFGhazy
  • 151
  • 7
8
votes
1 answer

Jest mock redux-store getState() used in module with redux-mock-store

So my implementation of the redux-store might not be the best and my knowledge of Jest is minimum-to-none.. I have three files which consists of... A module A React Component The (a normal) store, exported as default My test file looks like…
6
votes
6 answers

React Redux - Error passing several store enhancers to createStore()

I have a react app running redux and thunk which has all been working fine. I need to persist the store state on page reload so that data is not lost, so have created a function which is storing data in the localstorage and then returning the data…
Paul
  • 2,164
  • 7
  • 29
  • 52
4
votes
0 answers

How can I keep state that will not change inside Redux store?

I'm building a Single App that will do SSR (server side rendering) and I'm using React + Redux. I've just started to implement Redux in this app. It was previously built app using only React's useState, useContext etc. The fact is that sometimes I…
cbdeveloper
  • 14,014
  • 11
  • 57
  • 145
4
votes
1 answer

Configuring redux to display on all browsers is not working correctly

I followed the instructions over at the official docs; my app was working just fine in chrome, pointing to localhost:3000. However, now Im running into an issue, because it seems that if a browser doesnt have Redux extension, it won't work.…
Mike
  • 135
  • 6
4
votes
2 answers

How to use redux store of parent component

I am creating a component (- child) like npm package (- another project). This component will by use in another component (- parent) (will be installed like npm i child). So, my problem is that I want to use redux store architecture in a child. In…
user10536408
3
votes
2 answers

Redux state is mutating when editing local variable from useSelector()

I am using useSelector() to get state and when I apply some filter to local state variable, my global state is mutating. Not sure why. Below is the code. const filterVacations = (employees, status) => { if(status === 'Approved') { …
Kuldeep Bora
  • 1,094
  • 1
  • 8
  • 14
3
votes
1 answer

React Native, Redux: No Store Found

I'm using this extension to see my redux store. When I open my remote debugger, in the console I am connected to remotedev-server, but my redux tools says no store found. Below is my store setup import React, { Component } from 'react'; import…
Generaldeep
  • 377
  • 1
  • 7
  • 28
2
votes
1 answer

How does a react action have access to dispatch?

In my react project I have an actions file that looks like this: const startLoad = () => async (dispatch) => { dispatch({ type: CONTENT_LOAD, }); }; // Get all content export const getContents = () => async (dispatch) => { …
mastercool
  • 290
  • 2
  • 17
2
votes
1 answer

TypeError: Cannot read property 'carts' of null

This is my first time with Redux so please bear with me as I am not really understanding how this whole thing works. I am trying to gain access to my Redux Store in CartPlantContainer.js. When I console.log(this.props.user) I get: {id: 5, name: "b",…
BSAL
  • 21
  • 2
2
votes
1 answer

ngrx store select subscribe only for specific actions

I would like to know if it's possible to filter store.select subscription by actions (like we do in Effects). See the code below: this.store .select(mySelector) .subscribe(obj => { . //FILTER SUBSCRIPTION BY ACTION this.object = obj; …
Lucas Santos
  • 2,060
  • 2
  • 13
  • 23
2
votes
3 answers

How to add object at array index in reducer

I have store with arrays (store.calendar[0].todos[{title: title, etc...}]) 0: {todos: Array(0)} 1: {todos: Array(0)} 2: {todos: Array(0)} 3: {todos: Array(0)} 4: {todos: Array(0)} I need to add action object to the index…
HDallakyan
  • 540
  • 5
  • 20
2
votes
3 answers

Should I use Redux store.subscribe() or wrap my app with react-redux ?

I have seen the two approaches : in this example, which is taken from a course by Dan Abramov, he is using this approach : const render = () => { ReactDOM.render(
Albizia
  • 325
  • 5
  • 15
2
votes
0 answers

Redux Store not taking Image File

I have implemented a image uploader in my project. Image which I am uploading is working fine. I then wished to save the image to redux store instead of local state. So I created my actions and reducers and dispatched it. I get my file in the…
Ladoo
  • 169
  • 7
1
2 3 4 5 6 7