Estoy haciendo un mapa de Google con un botón de informe y no puedo entender cómo hacer que la página se redirija a otra página cuando se hace clic en el botón con la clase "informe-btn". Traté de usar pero no funcionó y no estoy seguro de cómo implementar esto.
export class MapContainer extends Component { state = { showingInfoWindow: false, activeMarker: {}, selectedPlace: {}, }; onMarkerClick = (props, marker, e) => this.setState({ selectedPlace: props, activeMarker: marker, showingInfoWindow: true, }); onClose = (props) => { if (this.state.showingInfoWindow) { this.setState({ showingInfoWindow: false, activeMarker: null, }); } }; render() { return ( <Map google={this.props.google} zoom={14} style={mapStyles} initialCenter={{ lat: 40.75901, lng: -73.984474, }} > <Marker onClick={this.onMarkerClick} name={"S Train - 42 Street"} /> <InfoWindow marker={this.state.activeMarker} visible={this.state.showingInfoWindow} onClose={this.onClose} > <div> <h4>{this.state.selectedPlace.name}</h4> <button className="report-btn">Report</button> </div> </InfoWindow> </Map> ); } }Tiene 2 solutions , use react-router-dom o window.location.href/replace
import { Link, NavLink } from 'react-router-dom';Deberías usar
import { Link} from 'react-router-dom'; return ( <Link to={"/somewhereyoulike}> <Button> somthiong </Button> </Link> )