In order to align a bit more closely with React patterns and remove the last selected global, extract creation of the map and updating selected rooms to use effects (also moving the styling to memo and the click event to a callback; I didn't do that with the other event handlers since they seem pretty static at the moment).
Rather than the global to track last selected, I'm using a cleanup function from an effect which sets the style for the selected feature.
In order to align a bit more closely with React patterns and remove the last selected global, extract creation of the map and updating selected rooms to use effects (also moving the styling to memo and the click event to a callback; I didn't do that with the other event handlers since they seem pretty static at the moment).
Rather than the global to track last selected, I'm using a cleanup function from an effect which sets the style for the selected feature.
I'm sure this could be further improved!
Loading and selecting is still working: https://github.com/user-attachments/assets/09886f28-ed9d-4938-9361-96dcf52bd187