@Andrey Prokhorov is right, and it's funny you asked. I found myself in the bowels of github issues earlier today and found this issue (Add
state as the third parameter to
mapDispatchToProps). While the title doesn't seem to relate, if you dig through the comments, gaearon (the creator of react-redux) explains:
Please take a look at #1. This option has been considered and rejected. Yes, it's very bad for performance to re-bind action creator on every dispatch, which is what will happen if we let people access the state in the same place they bind action creators. Technically they can still do it now with mergeProps but it's hidden well enough that people who aren't experienced with Redux don't discover it by mistake.
I also linked to the very first issue that gaearon linked to for react-redux where it was discussed (it was literally issue #1 on github for react-redux). I'm sure they COULD change it to the way you describe, but I think gaearon's comment sums it up:
The goal of this library is to encourage performant patterns because otherwise people will say “Redux is slow!” even if the cause is their suboptimal function binding code. We don’t want this to happen, so we’d rather make certain unperformant cases harder to implement.
- Why mapStateToProps and mapDispatchToProps are not just one function in Redux?
- Why are my props `undefined` when using redux and react.js?
- When using ES6, how can an imported function be undefined in one file, and not in another?
- Redux - mapDispatchToProps - TypeError: _this.props.setCurrentUserHandle is not a function
- How to fix 'module not found' for audio files using file-loader? Images, CSS, and JSON are working just fine
- Redux saga debounce and not just delay/cancel
- Why do componentWillUpdate() and componentWillMount() not trigger render function when setState used in these methods?
- Why does Redux Promise return unresolved promise if more than type and payload options are specified?
- In React why does calling a function from another function in our code not work and display?
- Why is `this.props.children` not an array when there's just one child?
- Why use react-redux and not just redux?
- gatsbyjs, reactjs - why components are rendering twice and images do not appear?
- react child/parent component - onChange event just takes one character and not retaining value
- Using React and Redux Hooks, why is my action not firing?
- map.getCenter and map.getBounds are not functions inside map.target.on('click') function
- Why objects are not valid as react children? What are valid children in react and why?
- Why is my object's values a function and not a string?
- Why are my POST and PUT requests from Node/Express not working in React/Redux? My GET and DELETE requests all work fine. All requests work in Postman
- Getting TypeError: Cannot read property 'localeCompare' of undefined for my sortBy function in my React component and I'm not sure why
- Why is my conditional function of adding an item from an array to another one not working?
- Why is this arrow function not firing, and how to properly call it?
- Why is React state the init state and not the state I just set?
- Why are the elements from a mapping function not rendering?
- Why does one function cause component to rerender but the other does not Nextjs?
- Why is Array.indexOf() working correctly with one redux action but not with another? (same reducer)
- Is there any reason React Redux Connect returns a function and not a component directly?
- Why getting the state of one function works and from other not?
- React: When passing in a function to one instance of a component, why are all other instances effected?
- Components not having the expected props, while React and Redux Dev Tools are having the expected States and Props
- React: same component reappearing multiple times in the app, how can I make sure that all states are captured accurately and not just the last?
More Query from same tag
- How to make a dynamic Firebase variable and not have it hardcoded
- Error when Using Custom React Hook in a Multi-Module Project for Tests with Jest
- Running a React app as a background process
- Nested route request interpreted as request for CSS file
- How to show the correct frame based of the changed current time of video
- ReactJS route URL generating by config
- ReactJS using axios post keep giving me error 400(bad request)
- How to make different color of markers in amchart
- Implementing Socket.io with ReactJS ES6
- How can I implement a real partial update with ReactJS?
- Cancel async Axios GET request - React hooks
- react-router-dom v6 <Link> reloads page when certain object is passed to state
- How to prevent multiplication of ipcRenderer listenters?
- 'rotate' is not defined React.JS
- Why is the state of a variable not updating correctly in the parent class
- React test checkbox doesn't checked on click
- component not rendering after setState in React.js
- Using React to call Nested API?
- Why isn't the mobx @computed value?
- Responsive background image in React
- REACT NATIVE - this.setState doesn't work inside onChangeText
- .map() is mapping the wrong value to my header tags
- How to filter values for multiple data using reactjs?
- Adding a svg line between 2 divs in flex box
- What's the correct way to do inheritance in TypeScript for React components?
- webpack 5 module.hot is undefined
- ReactJs state inside of nested function is not being updated, but it is updated outside(in fucntional component)
- How can i use a function in different files in React?
- React 0.13.1 rendering issue
- How to handle layout containers which do not match component hierarchy?