I have a Dashboard React component (parent) which contains N widget React components (children).
Each child has a widgetId
as the input which uses to call the back-end to get the data it needs to render the widget.
The dashboard has a date
parameter (synced and stored in the back-end database) which the user can change. When this changes, I need to re-render all the child widgets as their data will change.
But from a child perspective, their widgetId
remains the same (even though on the DB side, date
has changed).
How can I tell those child components to re-render themselves without passing the date
directly to them?
The reason I prefer not to pass the date
parameter to each child is that in the code there are many more parameters that can cause a refresh and passing all of those items to each child component makes my code messy.