0

Suppose that I have two components A and B and within component B I want to count the number of items in one of the states of component A based on some criteria set in component B.

In practice what I have is a table of values and when I click the a button I want to count all the values that have today's date but when I try to implement this the state containing that data is never initialized even though the table component has rendered correctly.

That that I am using hooks.

skyboyer
  • 22,209
  • 7
  • 57
  • 64
SonOfNye
  • 75
  • 8
  • This comes up a lot in react! I have answers to two similar questions, [How to set one component's state from another component in React](https://stackoverflow.com/a/62365670/2430549) And also: [Correct way to share functions between components in React](https://stackoverflow.com/a/51661103/2430549) Cheers! – HoldOffHunger Dec 27 '21 at 18:50
  • https://stackoverflow.com/questions/70417496/how-to-connect-two-components-in-a-same-component-created-on-click-of-add-button/70417750#70417750 – Reza Ghorbani Dec 27 '21 at 18:51
  • I don't think either of these addressed my question but thank you for the help. – SonOfNye Dec 27 '21 at 19:14

0 Answers0