React: Unusual writing of "state"

In one react tuto I saw an unusual writing of “state”. Here under an extract of the code. I don’t understand why the state is outside of the constructor. I can’t make link with any courses I did. Can I have explanations and documents I could refer to ?

class App extends React.Component {
  constructor(props) {
    this.loop = undefined;
  state = {
      breakCount: 5, // le temps de break qui paut être modifié
      sessionCount: 25, // Le temps de session qui peut être modifié
      clockCount: 25 * 60, //temps qui s'ecoule, il faut le surveiller car il passe en couleur rouge à une min de la fin.
      currentTimer: 'session', // text de l'horloge: Break ou Session
      isPlaying: false,
      loop: undefined
    handlePlayPause = () => {
      const { isPlaying } = this.state;

You can declare state using public class fields just like you are doing it with the arrow function.

Thank you lasjorg, I will study this later.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.