0

enter image description here

enter image description here

I'm trying to convert FC to CC and face problem. How do I substitute useHistory? is withRouter a good option? If yes then should I import it from react-router, or react-router-dom. What about dispatch and Redux in general? Spent a lot of time and could not find good example of Redux.

NOTE: I'm using Typescript, so all code should be written accord to its conventions.

  • Out of curiosity, why are you converting a functional component to a class component? From my observation the tide is moving toward functional components in the React community. – jtbandes Jan 03 '22 at 00:45
  • 1
    withRouter seems to be the correct replacement for useHistory. It causes the history to be passed to your CC via props. You should import it from the same library that useHistory was being imported from. Any older Redux tutorials from before hooks existed will likely demonstrate using class components. – jtbandes Jan 03 '22 at 00:47
  • I know fictional components are better and I prefer them as well. But this is just a task, so don't take it too serious – Djavid Hesenov15 Jan 03 '22 at 14:14

0 Answers0