MCPcopy
hub / github.com/reduxjs/redux / incrementIfOdd

Function incrementIfOdd

examples/counter/src/features/counter/counterSlice.js:66–71  ·  view source on GitHub ↗
(amount)

Source from the content-addressed store, hash-verified

64// We can also write thunks by hand, which may contain both sync and async logic.
65// Here's an example of conditionally dispatching actions based on current state.
66export const incrementIfOdd = (amount) => (dispatch, getState) => {
67 const currentValue = selectCount(getState());
68 if (currentValue % 2 === 1) {
69 dispatch(incrementByAmount(amount));
70 }
71};
72
73export default counterSlice.reducer;

Callers 1

Counter.jsFile · 0.90

Calls 3

getStateFunction · 0.85
selectCountFunction · 0.70
dispatchFunction · 0.50

Tested by

no test coverage detected