I am displaying a Popup when I click on a copy icon. When I click the copy icon, I set the state "showPopup" to true. My render function now sees that it's true, and displays the popup. The popup automatically closes if I click outside anywhere else.

So far so good.

The problem is I have a dropdown on the same screen with a list of selections. When I click any selection from the dropdown, it also changes another variable in the state which causes a re-render.

However, the previous state of "showPopup" is true and not false. So no matter where I click on the same screen now, I am always showing the popup. I only want it to appear when I specifically click the copy button. 

Any idea how I can fix this, I tried componentDidUpdate like so:

```
  componentDidUpdate = (prevProps, prevState) => {
    if (prevState.showPopup === true) {
      this.setState({showPopup: false});
    }};

```

But this causes an issue when the second time I try to click the copy icon again. This time the popup will only appear every 2 times I click the copy icon...

any idea how I can make sure that the initial state for showPopup is always reset to false?