Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

458
Vistas
How to send an onClick event using renderToString method in React
const _markers = floorEntities.map((floorEntity) => {
      return L.marker(floorEntity.latlng, {
        icon: getFloorEntityLeafletIcon(floorEntity),
        draggable: true,
      }).bindPopup(
        ReactDOMServer.renderToString(
          <Popup
            ref={ref}
            name={floorEntity.name}
            location={floorEntity.location}
            onClick={() => deleteMarker(floorEntity.id)}
          />
        )
      );
    });

The component has a prop called onClick which waits for a delete method, but the event wont go since we are using renderToString method which returns a dry HTML, is there any way to make onClick event get sent

Thanks.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you use the and components instead of creating the marker with L then you do not have to use ReactDOMServer.renderToString for the popup.

import { Marker, Popup } from "react-leaflet";
const _markers = floorEntities.map((floorEntity) => {
    return (
      <Marker key={floorEntity.id} icon={getFloorEntityLeafletIcon(floorEntity)} draggable>
        <Popup
          ref={ref}
          location={floorEntity.location}
          onClick={() => deleteMarker(floorEntity.id)}
        />
        Your content here :)
      </Marker>
    )
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda