Learning Redux
上QQ阅读APP看书,第一时间看更新

Class components – dynamic React components

To deal with state, we are going to turn our functional component into a class component. As an example, we will make a timer that shows how many seconds a user has spent on the page. First of all, let's write this timer as a functional component:

const Timer = ({ seconds }) =>
  <h1>You spent {seconds} seconds on this page!</h1>