score:1
nothing happens because the imported action creators are not bound to dispatch
(unlike their counterparts on this.props.actions
), so calling them simply returns an action object without triggering the reducer.
you can manually inject dispatch
to your props and then pass it to the cleanup
function, but the easiest solution is to install redux-thunk
, and write your action creator like this:
export const cleanup = () => (dispatch, getstate) => {
dispatch(cleanupx());
dispatch(cleanupy());
dispatch(cleanupz());
};
then you bind it at connect
like you did for the other action creators, and call it from the component with this.props.actions.cleanup()
.
installation of redux-thunk
is straightforward, just install the npm package and add it to the middleware of your store:
import { createstore, applymiddleware } from 'redux';
import thunk from 'redux-thunk';
import yourreducer from ...;
const store = createstore(
yourreducer,
applymiddleware(thunk)
);
Source: stackoverflow.com
Related Query
- React router v4 not working with Redux
- React Router 4.x - PrivateRoute not working after connecting to Redux
- IsValidated not working with redux in react stepzilla
- React Redux is not working as expected with Next.js & NodeJS
- combineReducers() not working in React Redux
- React Redux Mapping state to props not working
- Initial state in React with Redux not working
- React redux Form checkbox `defaultChecked` not working
- Protected Routes React Router 4 not working with auth state stored in Redux
- React Router / Redux / HOC not working with 'render' prop
- Private Route in react redux firebase not working
- React lifecycle hooks not working on redux state update
- react + redux + axios: actions not sent to reducers
- React Redux not updating state despite login working fine
- Hash routing Navigation is not working - react router redux
- map function not working after implementing redux in react
- React redux - pushing new item to the state array not working
- React redux search is not working properly
- Typescript React - Redux - Actions not reaching reducer
- React Redux onClick Call to Action Creator Not Working
- React Redux store state change is not working
- Multiple layouts not working under react router 4 and redux
- Delete action in react redux do not working
- fetchbyId in react wtih redux not working
- React Redux functional component updating state not working
- withRouter not working correctly with redux - react redux react-router
- React js actions not working
- React Redux - useState Hook not working as expected
- React Redux - Showing Dialog after posting data not working - Unhandled Rejection (TypeError): Cannot read property 'openDialog' of undefined
- React & Redux CRUD: Displaying a single item not working
More Query from same tag
- Error when trying to upload images to Firebase storage
- Code coverage concern on promise/asynchronous unit testing using nockjs and jest
- adding key to map function is not working
- setState update value but displays old value
- Reading input value always returns undefined ReactJS
- Dynamically highlight characters after certain length?
- What to use instead of window.getLocation() in a textarea in React?
- Array created in a Redux thunk is not being passed properly to the State tree
- React Testing Error: Uncaught [TypeError: Cannot read property 'map' of undefined]
- Prettier is not working at React project
- Typewriter effect text glitch in react
- Update external source for data with json after redux has changed
- Why is there a white "loading screen" before my page transitions in React Native?
- React js src attribute is not updating
- Jest jest.mock function with different return value
- Why is not my immer reducer returning the new value even though the draft have changed?
- Can't render the component received as a prop.children in my parent component
- click function in react was calling more than once even and there is no strict mode used in index files
- react can't access state from document/window keypress
- Accessing global variables in Sass with Webpack without multiple imports
- Dynamically import images from a directory using webpack
- React-Bootstrap-Table-Next Search Bar onSearch is not a function
- How to get value of textbox in React?
- start an accordion menu on a specific item in react
- Function inside a ReactJS called many times
- How to send URL parameter from react router to a toolbar?
- Is it possible to selectively pass DOM events through overlapping canvases?
- How to use replaceWithFragment in draft-js?
- What is the difference between server side rendering (Next.js) and Static Site rendering (Gatsby.js)?
- Unit Testing functions to check dispatch to be called