Home>

There is a comment counter in Reducer, made functionality when adding a comment and removing, respectively. But with a change in one, the number changes in the other too (That is, it is common). Can I somehow divide them into individual ones?

Please clarify your specific problem or provide more detailed information on what exactly you need. As it stands, it is difficult to understand exactly what you are asking.

Дух сообщества2021-12-30 16:12:12
  • Answer # 1

    I probably decided on a crutch, but still.

    In the post component, created a state. In its child component with displaying the number of comments, I passed only the value (state), and in the component, where all operations take place, passed a function with the state (state,setState).

  • Answer # 2

    I probably decided on a crutch, but still.

    In the post component, created a state. In its child component with displaying the number of comments, I passed only the value (state), and in the component, where all operations take place, passed a function with the state (state,setState).