alexkatz / react-tiny-popover

A simple and highly customizable popover react higher order component with no other dependencies! Typescript friendly.
MIT License
454 stars 121 forks source link

Making sure target is not null for components that renders null for a moment #29

Closed jmbastidas closed 5 years ago

jmbastidas commented 5 years ago

This fix comes when target (children) element sometimes renders null, so target will be null when popover componentDidMount is called making the popover to break. An use case of this is a themed button, so it renders null until theme data is loaded asynchronously, so HTML won't appear in the UI until CSS is ready, instead of having the mark up rendered with no styles and this way we avoid UI flickering. So by the time popover is mounted it is not possible to get the target and when target element is clicked popover will break the whole page.

This change makes sure to calculate target every time the popover is updated.

alexkatz commented 5 years ago

Thanks for pointing this out! Hopefully the issue is now fixed!