score:1

Accepted answer
class DetailModal extends React.Component {


  state = {
    showingMap: true,
  }

  toggleMapVisibility = () => {
   this.setState((prevState) => (
     {
       showingMap: !prevState.showingMap
     }
   ))
  };

  render() {
    const { showingMap } = this.state; 
    const { order } = this.props;
    return (
      <React.Fragment>
        <Button onClick={this.toggleMapVisibility}>Hide/Show</Button>
        {
          showingMap ?
            <Segment>
              <MapObject
                isMarkerShown
                lat={order.user.userAddressPoint.lat}
                lng={order.user.userAddressPoint.lng}
                googleMapURL="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=geometry,drawing,places"
                loadingElement={<div style={{ height: `100%` }} />}
                containerElement={<div style={{ height: `400px` }} />}
                mapElement={<div style={{ height: `100%` }} />}
              />
            </Segment> :
            null
        }
      </React.Fragment>
    )
  }
}

score:1

this.setState({ showingMap: !this.state.showingMap)};

More Query from same tag