Questions tagged [redux]
Redux is a predictable state container for JavaScript applications based on the Flux design pattern.
54 questions
-2
votes
1
answer
119
views
What is the best way to cache paginated data when any page can be moved to and page size is changeable?
I have a React Redux web app that fetches data from an Express/Node backend and MySQL database. I have a table of records that I fetch and store in redux as an array of objects, which I display as a ...
0
votes
0
answers
71
views
Best Practices for Managing State in React Applications
I'm currently developing a web application using React and I'm looking for the best practices for managing state effectively. I've come across several methods such as using the Context API, Redux, and ...
0
votes
1
answer
141
views
when would I need state management like redux in my e commerce app?
I am new to React and web development generally so please try to understand if the question seems dumb.
So, I am currently making a simple e-commerce app and I was thinking of using state management ...
0
votes
1
answer
153
views
How to actually use global state in React?
In my company, all of the projects use at least some kind of global state library like Redux and MobX.
However, the actual usage is limited to storing fetched data, and it lacks any caching logic or ...
1
vote
0
answers
139
views
Where should I persist the side effects of actions?
I have a outlining app that I am writing using unidirectional dataflow and some of the concepts from Redux.
When the user has selects items in the outline, and clicks indent, an indent action is fired....
51
votes
3
answers
7k
views
Are front-end state management tools an anti-pattern?
I'm currently reading "Code Complete" by Steve McConnell. In section 13.3 "Global data" in last paragraph "Don’t pretend you’re not using global data by putting all your data ...
0
votes
0
answers
339
views
Best route for multiple user roles with toggleable permissions with React and Django Rest Framework
What is the best way to create dynamic user roles that can have toggleable permissions?
I am currently creating my very first website which has a react front end with redux toolkit and redux saga and ...
2
votes
1
answer
1k
views
Are ViewModels within an NgRX store an anti-pattern?
I have a complex Angular app which has a large number of UI components. I have a central NgRX store. I have a 'pure' data model in the store which gets updated via the backend and via user input. ...
0
votes
1
answer
73
views
Organizing Data with Specific Group in Objects and Lists
So recently I have been working with a large-scale app that has a large number of individual objects with specific group attributes. For example, I have a list with objects such as
{Name: "Todd", ...
0
votes
1
answer
53
views
In Redux is it better for performance to add a property to the items in the store or to calculate it in the container?
I'm writing my first Redux app. In my store, I have ~300-500 Island objects that I retriev from an API and index by an id string in an object (being treated like a map). When I'm editing one of ...
1
vote
0
answers
24
views
Best way to allow other components to change table's focused row?
I have displayProjectTable that gets state from reducer projectData and populates itself.
Currently displayProjectTable has a local state that stores focusedRowID. My problem is that I want other ...
2
votes
2
answers
576
views
How could I reuse common JS modules between several projects?
At my company, we are developing pretty simple React Native and sometimes mobile-only React apps. Most of them have some similar logic, such as 'sign-in by phone' flow, some payments stuff, etc., and ...
1
vote
0
answers
138
views
Where to place code which synchronizes state of Redux with localStorage?
In our project, I was need to sync a piece of information between localStorage and the Redux state. Actually I subscribed to changes in a localStorage and in Redux, and if change happens in ...
2
votes
0
answers
48
views
How authorize web application and manage sessions
i am building a single page react app that uses redux as state manager and an express node js as backend server but i don't know what is the best way to authorize my users in the application!
if it ...
1
vote
1
answer
431
views
What do you call the state reducer pattern used by redux?
Redux uses a state reducer pattern where essentially you create a pure function that looks like:
function reducer (previousState, action) {
//...
return newState;
}
This looks similar to ...
5
votes
0
answers
58
views
Decoupling redux reducer tests from state shape
Recently I have been refactoring state shape in a fairly large redux application, and I have found that one of the obstacles to doing to is that the tests for my reducers clearly have a lot of "...
1
vote
2
answers
2k
views
How to effectively handle 404/500 http errors in server-side rendering web application which uses store for state?
I'm working on a website using server-side rendering approach. I'm using React and Redux for this. Redux handles the state of the application and provides API to change the state. All asynchronous ...
0
votes
1
answer
1k
views
"Fetch the data if it doesn't exist" selector?
Let's say I have a react component like this:
const MyComponent = ({data}) => (<div>{JSON.stringify(data)}</div>);
const myReduxSelector = (state, id) => state.someData[id];
...
4
votes
0
answers
564
views
How should a non-React component subscribe and respond to Redux state changes?
I’m new to React/Redux tools and still figuring out some idiomatic design patterns.
Here's a scenario:
A user adding a place marker 📍 (that has some associated metadata) to an interactive map (...
0
votes
1
answer
188
views
Correctly store device info with Redux in React Native app
I'm currently building a React Native application and wondering if storing device information such:
if my app has granted location permission
location service is turned on
last known user location
...
0
votes
2
answers
131
views
Should / When to create javascript object to serialize data?
I'm working on a React/Redux application. I receive a data object from the api resembling this:
const dataObj = [
{
id: 1,
name: "Filo",
activity: 9,
info: {
statusCode: 4
...
1
vote
2
answers
1k
views
When using Redux/Redux-Saga - should JWTs be set in the action creators/sagas?
Almost every blog post I've encountered around generic auth handling using JWTs in a React/Redux/Saga application does the same thing, which is to store the JWT in local storage, in the action/saga.
...
5
votes
1
answer
7k
views
Redux LOADING/SUCCESS/ERROR pattern - when using redux-saga
On a typical web app, we commonly have to deal the LOADING/SUCCESS/ERROR problem - which is that:
When I make a backend request I want to display a loading cursor, perhaps disable some buttons.
...
4
votes
1
answer
3k
views
React: Redux vs Singleton service [closed]
An application I'm currently working on in our front end we currently use React, Redux and some singleton services (wrappers around some 3rd party libraries). We started discussing a new feature which ...
-1
votes
1
answer
96
views
My action creators and reducers all mostly look the same - is this a code smell?
Most of my redux actions are 'fetch some data from the database, here's the authentication token', and they for the most part look the same, like this:
action creator
export const fetchDashboard = ...
0
votes
2
answers
193
views
React and redux app-wide translation best practices
My team and I want to translate an entire React-redux app into another language (english to arabic) and have a switch that does the app-wide translation via a redux action. The content for the first ...
0
votes
0
answers
207
views
Is giving sub reducers access to the full state a bad idea?
I've got a Redux app with a fairly flat state tree. All sub reducers handle one separate part of the state, and they are tied together with combineReducers.
My problem is that in a few cases I need ...
3
votes
0
answers
73
views
How does "redux" decouple the different components so they can be tested separately in unit tests?
In the past we saw a big move from traditional MVC to MVVM for user interfaces:
One of the primary motivations for MVVM is that the view and viemmodel are competely indepedently of each other and ...
1
vote
1
answer
214
views
OrderedMap or List for Redux structure?
I'm implementing a Redux store for a React app using redux-saga for API calls. I've used Immutable.js before for other Redux-using React apps but the nature of previous projects always evidently ...
1
vote
1
answer
497
views
Organizing reducers in Redux
I will use the following popular todo list example for demonstration. Let's say I wanted to create a very basic todo list with this structure as the app state:
{
todos: {
todoKey1: {
...
2
votes
1
answer
125
views
Does Flux/Redux concept about application state put bounds on the size of application?
In Redux (React Flux implementation) guide https://redux.js.org/basics/reducers it is said, that
In Redux, all the application state is stored as a single object
My questions are:
How seriously ...
0
votes
1
answer
8k
views
Best Practice for handling data sync with React Native, MobX and REST?
We're developing an app using React Native and MobX for the state stores, and also using a Web API REST service for the GETs and POSTs. All is going well, so far we're able to use FETCH to get the ...
0
votes
1
answer
338
views
how to design redux actions involving chained side effects?
I am designing redux actions for a user signup. Signup process requires three entities to be created User, UserProfile and an Offer and involves side effects to handle async server calls.
I wonder ...
1
vote
1
answer
416
views
How should I structure React Redux components when requesting Data From an API?
I have a search box I'm going to use on different pages (I use the term 'page' loosely here).
The search box puts its value (the search string) into the Redux state.
The results are populated from an ...
-2
votes
1
answer
66
views
Single Page Apps: handling state dependencies
If I have an React/Redux single page application that has - say - a customers page that lists businesses that are customers, and from there each customer can be accessed with a URL like this:
/...
3
votes
0
answers
320
views
Redux Saga pattern for large, non-specific server responses
Our current Redux state tree is this:
{
"dog": {
"name": "Barkley",
"age": 6,
"hungry": false,
"location": "Living Room",
"height": "36 in."
},
"...
2
votes
1
answer
376
views
react-redux (React bindings) vs Virtual Dom and Single responsibility principle
I understand React and Redux (at least think that I do). But the combination using the react-redux Binding package is a bit confusing to me.
https://github.com/reactjs/react-redux
The first thing ...
0
votes
1
answer
298
views
Redux: When Should I Keep Track of State and When Should I Not?
NOTE: I am new with the whole concept of state management. I never got into the older languages that "explicitly used" states.
I dived into React and Redux for the past week, and as I'm getting into ...
-2
votes
1
answer
438
views
HTML5/Canvas Graphics editor and Immutable state (EaselJS and Redux, ngrx/store)
This question is about the architecture approach.
How would someone go about creating the immutable state for a graphics editor that would eventually provide an "undo/redo" functionality, considering ...
1
vote
2
answers
378
views
React / GraphQL / Redux design question: Looking for a good practice
A React website I am building is going to have these sections: Hero, Projects, Courses, Skills and a few others. The Skill section will iterate though a list of skills and display a React component ...
0
votes
1
answer
240
views
Does Angular2 or Angular4 offer an app state and middleware promise like React / Redux?
I used Angular 1 and React / Redux, and one thing I like about React / Redux is that there is a definite app state, and a middleware that can convert a promise into real data.
In Angular 1, we often ...
3
votes
1
answer
620
views
What is a (Redux) selector?
I am learning Redux (a JavaScript state container tool). I am finding numerous references to something called a "selector" (e.g. here, here, here, and here). However, I don't seem to be finding a ...
2
votes
1
answer
232
views
Does AngularJS or Angular 2 provide something similar to the Redux middleware so that AJAX data appear immediately available?
I am learning React / Redux, and one feature I like is, when you fire off an Action, you actually provide a request as the "result" or what is called the payload in Redux, and the Redux middleware won'...
0
votes
1
answer
704
views
Functional model vs data model and react/redux
I have a module object, that consists of several parameters and an algorithm.
A parameter consists of a min, max, step, label and value.
The module's algorithm is regularly making a calculation ...
4
votes
3
answers
223
views
How do I manage dependant values without running the same computation twice?
I am working on an application that is essentially a calculator, not the handheld calculator but more of a spreadsheet. It will take many inputs across different views and show the outputs all over ...
1
vote
1
answer
2k
views
How to avoid get/set actions in redux?
The point of redux is to decouple "what happened" from "how the state changes" according to Dan, anyway, but I'm having trouble figuring out how to handle side effects without having getters and ...
17
votes
3
answers
3k
views
Is Redux using a sanitized God object pattern?
While learning about Redux, the God-object pattern(or anti-pattern) came to my mind- both have a single big object holding all the app data and methods to manipulate them. But Redux has put some ...
1
vote
0
answers
648
views
How to design the state tree using redux?
In the last days I have searched for a documentation on how and when is it best to use redux and how to design the state tree.
My research ended in the conclusion that there is no one correct answer.
...
3
votes
1
answer
974
views
Do we need redux here?
In an ongoing project my team is building a new web application that relies heavily on a rest api. As we decided to try react we naturally came to implement redux and a middleware, as we've read this ...
1
vote
2
answers
1k
views
How to structure a REST API response for a Flux/Redux frontend?
I have a question about how to structure a response where I return objects related to other objects (one-to-many/many-to-one), and to tell me if the way I've structured my endpoints are wrong or not, ...