export function getDeckCards() {
return dispatch => {
axios
.get("http://localhost:4000/card/cardInfo")
.then(res => {
dispatch(showCard(res.data));
})
.catch(error => {
console.log(error);
});
};
}
const reducer = (state = initialState, action) => {
switch (action.type) {
case SHOW_CARD:
return Object.assign({}, state, { cards: action.cards });
default:
return state;
}
};
componentDidMount() {
this.props.getDeckCards();
}
...
<Link
component={RouterLink}
to={`/study/${cate_route}/${title}/${
cardIdArr[currentIdx - 1]}`}>
<Button variant="outlined">previous card</Button>
</Link>