Questions tagged [mapstatetoprops]

58 questions
0
votes
1 answer

Redux, MapStateToProps/useSelector: Is it safe to mutate those values

Both MapStateToProps and useSelector work with similiar callback store => store.group Is it safe to mutate those values for example in MapStateToProps like this: const mapStateToProps = store => { const { group, level } = store; let { group } =…
Katzhuu
  • 132
  • 1
  • 8
0
votes
1 answer

props are undefined when using mapStateToProps

In my app I use mapStateToPros like that: const mapStateToProps = (state:any) => { return { cardsAndBalance: state.cardsAndBalanceReducer } } In debug when I stop at return I can see that I have some data in state. When I stop the app…
Keselme
  • 3,779
  • 7
  • 36
  • 68
0
votes
1 answer

Can't get Redux mapStateToProps work on one out of four Components

I use React Redux Saga and have 3 Components that receive mapStateToProps ok when Sage is dispatching to my reducer. The fourth Component don't fire the render() even I place a break point console.log in the render() on the Components: const…
Kid
  • 1,869
  • 3
  • 19
  • 48
0
votes
0 answers

What is the correct way to implement text filtering with React and Redux?

I have a component with a list of ToDos with a SearchBar above to filter the ToDos. The ToDos are stored in the Redux store because I also need them in other components. But the SearchTerm is a property of the component state because I need it only…
0
votes
0 answers

Props are not defined with react-native and redux

I try to connect the state to the props in one of my components. When mapPropsToState(state) is called I can see that the state is exactly what I want it to be. However, when I try to log the props I get an error stating: Uncaught ReferenceError:…
Keselme
  • 3,779
  • 7
  • 36
  • 68
0
votes
1 answer

Can't read length of array in JSX (React-Redux)

Simple enough question. I am trying to read the value of the "length" variable inside this array of objects (See Image 1) MY CODE const mapStateToProps = (state, ownProps) => { const lecture = state.firestore.ordered.lectures; const…
Andrew B.
  • 245
  • 3
  • 12
0
votes
1 answer

How to iterate through an array of objects and return one that has a specific object ID using JSX (in mapStateToProps of React-Redux)

I am trying to pass an object (called a lecture) to the props from state using mapStateToProps. The object exists in an array of objects. I believe I am making a syntax error but am uncertain on exactly what is the correct syntax should be because…
Andrew B.
  • 245
  • 3
  • 12
0
votes
1 answer

Why states are still undefined after being passed to props via mapStateToProps?

const mapStateToProps = state => { console.log(state); return { counter: state.counter, isLogged: state.isLogged } } This is how I passed the states. However, error comes saying counter and isLogged is undefined. Why ?
0
votes
1 answer

(Error) Passing data from one component to another using React-Redux mapStateToProps + Reducers

After spending hours trying various methods of passing data from one component to another I am completely lost as to why the code below doesn't work. Purpose: I am simply trying to pass a "courseID" (a string) to the app's state during a "NavLink"…
Andrew B.
  • 245
  • 3
  • 12
0
votes
1 answer

React-Redux mapStateToProps with dynamic (uid based) path

I am new to React and React-Redux. I'm trying to pass "mapStateToProps" using a dynamic pathway depending on the users id. The basic code being used follows: const mapStateToProps = (state) => { console.log(state); …
Andrew B.
  • 245
  • 3
  • 12
0
votes
0 answers

mapStateToProps is not calling when same route is called again

Firstly, I'm using "react": "^16.13.0", functional components only, not classes, along with "react-redux": "^7.2.0", "react-router": "^5.2.0", "redux": "^4.0.5", "redux-saga": "^1.1.3", "webpack": "^4.42.0", I've 2 components in react component -…
0
votes
1 answer

How do I fix "Computed property ... was assigned to but it has no setter" error in Buefy b-table component using Vuex store

Situation: I have a VueJS2 app with an array of items in my Vuex store: export default new Vuex.Store({ state: { checkedItems: [] } ... The idea is to have the checked (selected) items in a buefy b-table component globally…
user1729972
  • 712
  • 2
  • 9
  • 29
-1
votes
1 answer

Why the reusable props is not working and show undefined

I had to use the boolean hook expression i.e isMainPage. The logic is if isMainPage is true then the className is mainPageActive if not then it should be mainPage, But the main problem is the props that I had put in the main component are showing me…
1 2 3
4