All Questions
Tagged with state react-redux
210
questions
1
vote
1
answer
571
views
Redux + Selector unknown returned the root state when called. This can lead to unnecessary rerenders. ... warning + where state is an array
I am using Redux 5 in my React 18 application. When using the useSelector() method from the react-redux package, I get the below warning in the browser console:
Selector unknown returned the root ...
-1
votes
1
answer
37
views
React using toggle switch to change state of sibling components
I'm working on an app where I want to change a value from lbs to kgs. I currently have the state set to lbs and am trying to add a toggle switch which will allow users to toggle between lbs and kgs. I'...
1
vote
1
answer
140
views
Redux state and useSelector returning undefined when trying to set state on Login
I'm trying to decode a JWT when a user logs in on my app in order to get what kind of roles and access the user should have for the application. I get the roles fine from the token but it's trying to ...
1
vote
1
answer
18
views
Updating the state with fetched data but when trying to console.log it gives 'undefined'
When I fetch data on render or on change of some dependencies it updates in Redux store properly but when console.loging it gives 'undeifined'.
I am developing booking system and want to fetch already ...
0
votes
1
answer
77
views
Should I mix variable and constant data inside a react state?
I'm trying to think about the data structure of my app and came into an interesting question:
I have some data that will be defined inside my code (without fetching) and won't change during the ...
0
votes
1
answer
126
views
React - trying to change state in child component from function in parent component
class ParentComponent extends Component {
state = { isDialogOpen: false }
handleClose = () => {
this.setState({ isDialogOpen: false })
}
handleOpen = () => {
this.setState({ ...
0
votes
1
answer
17
views
Redux Reducer Mystery On full State upload
Why can't update the entire state at once on Redux?
Look this typical Slice working Perfect as usually:
import { createSlice } from '@reduxjs/toolkit'
const initialState = {
userName: "pepe&...
0
votes
1
answer
72
views
MUI Autocomplete: How to update the redux store , when clear input options?
I'm trying to do when the user clear the input I have to update the react-redux store. Thanks
<Autocomplete
multiple
id="tags-outlined"
options={filters}
onInputChange={(event, ...
0
votes
1
answer
336
views
Redux toolkit useSelector return undefined
when I log in I dispatch the login, setUserToken, setUserData reducer functions and I console.log them and I see that their state has been updated as intended.
but when I try to receive the data back ...
1
vote
1
answer
55
views
Redux selector using incorrect state slice
Im currently doing a flashcards project from codecademy.com which involves making a flashcard application using React and Redux where you create a topic and then you can make quizzes for each topic, i ...
1
vote
2
answers
490
views
Part of which architecture layer is React Redux?
I have recently read "Clean Architecture" by Bob Martin. Even though the principles he explains there apply to all languages it is harder for me to grasp those concepts around JavaScript (...
2
votes
1
answer
122
views
Can you have slices inside slices? How to share state logic between slices?
EDIT: For complete reference, Im trying to do this with Redux
https://codesandbox.io/s/github/SenBoyer/codm-tracker-unfinished
For quick visual reference:
https://jsfiddle.net/59r31Lmt/
Im trying to ...
0
votes
2
answers
244
views
What is the best approach to reset state array of object in react js
I am trying to reset an array of object but I am unable to do it without rewriting the initial value of the state again.
Initial state
const [state,setState]=useState([
{name:'abc',age:24},
{name:'...
2
votes
0
answers
480
views
Combining multiple reducers into one state reducer
I am experimenting with my code, and i was wondering if there was a cleaner way to combine the reducers with the combineReducers function.
for example, in my current reducer setup i have:
productList: ...
0
votes
0
answers
240
views
React - ReduxJS auto log out feature
I am trying to make auto logout feature based on auth token expiring time. When certain time expires, It should automatically log out. I've tried with few solutions but could not come to resault (...