FlorianCousin / use-tabs-state

Hook for React state that is shared through all tabs
GNU General Public License v3.0
1 stars 0 forks source link

Initialisation makes too many rerenders #6

Closed FlorianCousin closed 3 months ago

FlorianCousin commented 3 months ago

When a new tab uses the shared state, there are a lot of rerenders: as explained in the drawback part of the ADR).

Is it possible to improve this ?

FlorianCousin commented 3 months ago

For example, we could manage data initialisation in another event channel, and have a boolean that says if the state has already been initialised or not.

The boolean starts at false, and gets the value true if is receives an initialisation data event or an initialisation tab event.

If the boolean is true, then ignore all the initialisation data event.

FlorianCousin commented 3 months ago

We could use something similar to the boolean above, but instead of passing the boolean to false, we remove the listener on initialisation data event.

I am not sure it is possible though.