make sure the initial hidden state of the legend component matches the visibility of the layer, this will prevent legends showing up after drag and drop even if the layer itself is not visible