Change the state when clicking outside a component in React
问题 I have a dropdown as is shown in the following image: When I click the folder icon it opens and closes because showingProjectSelector property in the state that is set to false. constructor (props) { super(props) const { organization, owner, ownerAvatar } = props this.state = { owner, ownerAvatar, showingProjectSelector: false } } When I click the icon, it opens and closes properly. <i onClick={() => this.setState({ showingProjectSelector: !this.state.showingProjectSelector })} className='fa