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

117
Views
html-react-parser with react-swipible-views return empty slides

I am using headless wordpress for content generation. It returns pre-generated html. I put it in react using a plugin Html-React-Parser. The plugin also allows you to replace elements. At this point, I change the wrapper of the slider to a component. And I put child elements inside with domToReact(children). On startup, I expect to see a done slider. But there is an empty div in front of each slide. I maked sandbox where you can see this problem.

https://codesandbox.io/s/interesting-booth-1jhyvm?file=/src/App.js

import SwipeableViews from "react-swipeable-views";
import parse, { domToReact } from "html-react-parser";

const html = `
<div class="slider">
  <div class="slide">123</div>
  <div class="slide">456</div>
  <div class="slide">789</div>
</div>
`;

const options = {
  replace: ({ attribs, children, data }) => {
    if (!attribs) {
      return;
    }

    if (attribs.class === "slider") {
      return (
        <SwipeableViews enableMouseEvents>
          {domToReact(children)}
        </SwipeableViews>
      );
    }
  }
};

export default function App() {
  return (
    <div className="App">
      {parse(html, options)}
    </div>
  );
}

about 4 years ago · Santiago Trujillo
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!