hms-dbmi / viv

Library for multiscale visualization of high-resolution multiplexed bioimaging data on the web. Directly renders Zarr and OME-TIFF.
http://avivator.gehlenborglab.org
MIT License
274 stars 42 forks source link

React Context / update Zustand #746

Open xinaesthete opened 9 months ago

xinaesthete commented 9 months ago

Background

This refactors to use React Context, as a step towards allowing more of Avivator to be used as a library, as per #745

Change List

To the best of my knowledge this doesn't impact functionality or performance - pretty sure the current pattern doesn't incur any extra renders or unnecessarily expensive Zustand calls, but I could be mistaken.

I've run tests/lint etc as well as manually testing most features in the Avivator UI.

Checklist

ilan-gold commented 9 months ago

@xinaesthete We will accept the PR. I will review soon.

xinaesthete commented 9 months ago

Another thing you might want to check as you review is whether the 'equality function' stuff looks right & isn't applied in the wrong way anywhere. That part of the PR was because of Zustand warnings but I suppose could be a place where there's potential for me to've done something sub-optimal, or that might need to change yet again with subsequent Zustand update (https://github.com/pmndrs/zustand/discussions/1937). Anyway, if anything does need to change now or in future, it will be in a very focused part of the code I believe.