Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

457
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!