All Questions
69 questions
1
vote
1
answer
221
views
Avoiding type assertion when using useSelector with Redux, Immutable.js, and TypeScript
I'm currently working with a combination of Redux, Immutable.js, and TypeScript. I'm having trouble getting proper types from the useSelector hook, and I've resorted to using type assertions. I ...
1
vote
2
answers
2k
views
Update deeply nested state object in redux without spread operator
I've been breaking my head for a week or something with this !!
My redux state looks similar to this
{
data: {
chunk_1: {
deep: {
message: "Hi"
}
},
...
2
votes
4
answers
160
views
How to make a promise object immutable when setting different states in Javascript?
I'm working with React/Redux and want to use the same Promise result to set two different states. Here's my code:
useEffect(() => {
fetchData().then((resp) => {
Object.freeze(resp);
...
0
votes
1
answer
396
views
Merge state objects in Redux
My state consists of settings selected by a user to view charts in the application. Each time a user logs in I get their respective settings from the database. I also have an initial state defined in ...
1
vote
1
answer
2k
views
Wait for react state/props to update before using data?
I am using react-redux with persist-store in my react app. Once the user logs in, the state contains user data i want to use to customize the app and display their name and other info. It works ok ...
2
votes
1
answer
9k
views
Why does React/redux state reset on refresh?
When i login, everything works fine but the moment i hit refresh or navigate somewhere else, the state gets reset. Any idea why? I want to be able to reference the user from the state and get info ...
0
votes
1
answer
684
views
how to pass initial state value using immutable js
I am using immutable js and in my reducer I am initializing the state like this:
export default function reducer(state = new Map(), action = {}) {
switch (action.type) {
case ...
1
vote
2
answers
4k
views
TypeError: state.getIn is not a function
I'm implementing immutable on my react project, using it with redux, making state an immutable object using fromJS() function (from immutable library). In my reducer file, everything works, I receive ...
2
votes
1
answer
1k
views
Immutable data in Redux - Spread vs Object.freeze vs ImmutableJs/Immer
I'm trying to get my heading around why in Redux they recommend using ImmutableJS when editing the initialState. I've read the official docs but it's still a bit unclear. When editing state in a ...
0
votes
0
answers
1k
views
How to use react-hooks with redux and immutable js?
I am using react, redux with immutable js. I am facing a problem when I use useEffect or similar hooks with non-primitive data that effect is running even though it hasn't changed as I am using hoc ...
1
vote
1
answer
1k
views
reselect selector always returns a new reference to array
I'm adding a new feature to a project and since I'm writing the reducer from scratch I decided to finally give normalized state, reselect and immutablejs a go.
However, my selector keeps returning a ...
0
votes
1
answer
115
views
How can I use "home" state within "global" reducer?
I have a react, redux-saga, immutable js app.
With this architecture, my redux store is like this.
global: {
notifications:{...}
...
},
home: {
...contents
}
The problem is when I want to ...
1
vote
2
answers
2k
views
How to compare two redux store states?
I am writing tests for my reducers and would like to compare state before dispatch to state after - actually 'substract' before state from after state
describe('UpdateAccountData', () => {
let ...
1
vote
1
answer
711
views
Arrays and Objects cause unnecessary re-renders with Redux and Immutable.js
In my React project I have Redux state that is shaped something like this:
{
items: [{ ... }, { ... }, { ... }, ...]
form: {
searchField: '',
filter1: '',
filter2: '',
}
}
On one ...
0
votes
0
answers
102
views
Rendering when mapping over normalized redux state
I am using the normalized state pattern, and need to render all objects in a part of the state tree, so I am attempting to map over them and render. But the indices keep rendering along with the ...