Answer the question
In order to leave comments, you need to log in
What is the error when switching the year?
Going through this great tutorial https://www.gitbook.com/book/maxfarseer/redux-cour... I
encountered the following annoying error when switching the year
prntscr.com/ihoy4i
and when passing the setYear function through a prop to the page component I catch the following
prntscr .com/ihp2zf
actually the code itself
https://codesandbox.io/s/7znywy46lj
ask for help
Answer the question
In order to leave comments, you need to log in
https://codesandbox.io/s/mopx1nzpkj
you have a bunch of little errors
1 you didn't enable connect and therefore the component doesn't know about the setYear function
2 you display the year as {year} but as soon as you click on 1 of the year buttons you go to the reducer put not a number, but an object return { ...state, year: action.payload }
, it will return you {year:2017} and in the component you need to access it like this {year.year}
at this moment const { year, photos} = this.props you will receive your data in the component. Print them to the console and then it will become a little clearer what your errors are
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question