ATIX-AG / foreman_resource_quota

Foreman plugin to allow resource management with Resource Quotas among users and usergroups.
GNU General Public License v3.0
4 stars 0 forks source link

Remove react-dom/server dependency #51

Closed bastian-src closed 2 months ago

bastian-src commented 2 months ago

ReactDOMServer has been used to compare React components. Such comparison is not necessary and therefore, the dependency can be removed.

When placing the updateResourceUtilizationView()-call right in the component, it might be called several times due to re-rendering. In order to mitigate re-setting issues, it was important that the updateResourceUtilizationView function sets the corresponding values (setResourceUtilizationPercent and setResourceUtilizationTooltipText) only once/when they actually change. To recognize such change, the helper-function areReactElementsEqual was implemented which compares React components. This adds a dependency to react-dom/server.

The comparison helper-function, and therefore the dependency, can be removed by moving updateResourceUtilizationView() in a useEffect() that is called only once (see here).