score:5
Accepted answer
there is a third argument called mergeprops in connect
method of react-redux
which is supposed to be used in cases like one you just described. in your case you can do something like:
const mapstatetoprops = state => ({ postdata: ... });
const mapdispatchtoprops = (dispatch) => ({
actions: bindactioncreators(formactions, dispatch)
});
const mergeprops = (stateprops, dispatchprops) => ({
submit: () => dispatchprops.actions.submit(stateprops.postdata),
});
const connectedcomponent = connect(mapstatetoprops, mapdispatchtoprops, mergeprops)(component);
note that component will not receive actions
nor postdata
, just submit
.
Source: stackoverflow.com
Related Query
- Bind action parameters in mapDispatchToProps
- What's the use of mapDispatchToProps when we can just use this.props.dispatch to dispatch action
- React Redux - How to dispatch an action on componentDidMount when using mapDispatchToProps in a connected component
- React bind in constructor, how to pass parameters to props
- mapDispatchToProps not working. Props empty (error: redux action is not a function)
- Pass values as parameters state from the component or access the status in the action creator?
- React-Redux: What is the canonical way to bind a keypress action to kick off a reducer sequence?
- How to dispatch more than one action in mapDispatchToProps in react-redux
- Action mapped with mapDispatchToProps does not take parameter
- How to take parameters from component to redux action creator
- Dispatch with multiple parameters and create action with Redux Toolkit
- mapDispatchToProps dispatch action working for only one function
- How to Write A Typed Action Without Parameters
- Trying to return a promise from an action creator dispatched from mapDispatchToProps
- Bind different action creator on different pages
- How trigger mapDispatchToProps action in button?
- React-redux: mapDispatchToProps does not dispatch action
- React Hook useEffect has a missing dependency for redux action as parameters
- How to bind action creator to component in redux thunk
- Redux mapDispatchToProps access action within array.map
- how to pass parameters to a callback method when you have used the constrocer to bind it?
- Action not mapped with mapDispatchtoProps
- mapDispatchToProps dispatch action not working to update State
- How to bind event handler in contructor and call it with parameters in React?
- How to get mapDispatchToProps method to dispatch action
- Run function before dispatch action in mapDispatchToProps in redux
- React mapDispatchToProps Object Action Doesn't Work
- Can not invoke action after connect react-redux and mapDispatchToProps
- How can I use my action from redux without mapDispatchtoProps but with useDispatch?
- Can't export action creator to component mapDispatchToProps method
More Query from same tag
- Console.log not working on Reactjs app
- Passing in Redux state to React Component
- Mongoose/Mongodb getting .deleteOne is not a function
- How to set values from an array objects to dynamic rows in ReactJS?
- ReactJS: change route based on click event
- how i can Make my dashboard protected component (Only registered user have access).And how dashboard navigation work
- 'FontAwesomeIcon' is not defined
- Why delete method doesn't work when post method does?
- Trying to reload what's inside componentDidMount
- Import modules into next js
- trying to send querystring parameters to another page using reactJS
- Bootstrap modal closes while clicked on the modal content body
- api endpoint dependent on another one
- Preflight Request doesn't pass access control
- radio inputs repeating on selection (React)
- I am trying to set data in state everytime on first index for react in array of object
- react button conditional rendering not working
- REACTJS button that show and hide a component when you click
- Which event to use when React app finishes loading
- Really not support async setState of React Hooks?
- How to fetch image names from database and display them in react app
- Passing props to a react component wrapped in withRouter() function
- clear token cookie using react js after logout
- React and d3.js, how to ensure d3 component renders upon `.setState()`
- Trying to hit an API with JSON data in REACT
- How to add files using JSZip from remote URL in ReactJS?
- Convert array to object without sorting keys in javascript
- create react app with github pages, not updating
- How to flatten the reddit comment data structure?
- Redirect doesn't work in React Router