Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

461
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda