'Add layer to react-leaflet MapContainer after 1st render (dynamically)

is it possible to add a layer to react-leaflet v4 dynamically? i.e. after the MapContainer and all its children have rendered.

use case example: user selects a date from a calendar widget to load a specific image to the map e.g. a TileLayer. The problem is that the dates go back years, so I cannot simply preload a component for each image and just show it if the user selects it.

I am looking for a best practice for doing this in react-leaflet. It is very simple with plain JS and leaflet... But I'm new to react-leaflet and things work a bit differently.

TIA



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source