Questions tagged [redux-store]
141 questions
631
votes
36 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
- 6,315
- 3
- 12
- 6
16
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
- 181
- 1
- 7
8
votes
1 answer
How to implement redux-toolkit and next,js and not lose SSR
I'm trying to implement redux-toolkit in my Next.js project without losing the option of SSR for the data I'm fetching from an external API. I have followed the example in next.js GitHub but doing so led to not having SSR when fetching data in my…

yalda karimi
- 81
- 1
- 3
8
votes
8 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,465
- 8
- 35
- 60
8
votes
1 answer
Inject middleware after redux store creation
I'm wondering if there is a way to inject a Redux store middleware after the store creation?
I'd like to have something like:
injectMiddleware(store, [middleware1, middleware2]);
In a similar way, we can replace the root reducer on the fly after…

alexmngn
- 9,107
- 19
- 70
- 130
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…

Alejandro Andersson
- 101
- 1
- 6
5
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
4
votes
0 answers
Typescript npm library can't export Redux store please advice
I use the Notistack library and forked it and then using VSCode to try to add a Redux store in the library that I want to expose to Apps.
I'm not so good with Typescript. I have some trouble hehe.
What I want to do is that when the app is using…

Kid
- 1,869
- 3
- 19
- 48
4
votes
1 answer
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
- 27,898
- 37
- 155
- 336
4
votes
2 answers
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,991
- 3
- 19
- 29
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
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
- 4,072
- 3
- 12
- 16
3
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
- 517
- 8
- 18
3
votes
1 answer
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
- 179
- 8
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
- 437
- 2
- 12
- 30