Created
July 5, 2020 17:36
-
-
Save mjstelly/ecbbdfa94f50ad730e2d5339a1104ce4 to your computer and use it in GitHub Desktop.
redux action fails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//calling module | |
import { setTab } from "../../../shared/store/actions/navAction"; | |
<Tab | |
label={translate.tabAll} | |
selected={tab === 1} | |
onPress={() => { | |
setTab(1); //no console response when selected | |
}} | |
/> | |
// action types | |
export const SET_TAB = "SET_TAB"; | |
//navAction | |
import { SET_TAB } from "./actionTypes"; | |
export const setTab = (tab) => { | |
console.log("setTab action"); // log output | |
return async (dispatch) => { | |
console.log("setTab return"); // no log output | |
dispatch({ | |
type: SET_TAB, | |
payload: tab, | |
}); | |
}; | |
}; | |
//navReducer | |
import { SET_TAB } from "../../store/actions/actionTypes"; | |
const initialState = { | |
selectedTab: 1, | |
}; | |
export default (state = initialState, action) => { | |
switch (action.type) { | |
case SET_TAB: | |
return { | |
...state, | |
selectedTab: action.payload, | |
}; | |
// blah blah... more cases | |
default: | |
return state; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment