AEM React SPA - Extra Divs - Decoration

satishak9342628

29-10-2019

We are working on AEM-React SPA integration. We see a set of extra Divs (Decorator DIV wrapping component) in the rendered HTML in the stand alone react app (npm start) bloating up the html. Is there any way to remove them from bloating the html ? There are lots of examples on the internet, and forums

But not much is discussed about how to fix this in the AEM React SPA. Have tried the example in the links mentioned but they don't work. Can i get help on how to remove the decorator DIV wrapping component in the AEM React SPA ?

I am using AEM 6.4.6.

Accepted Solutions (1)

Accepted Solutions (1)

Jörg_Hoh

Employee

29-10-2019

When you mean "AEM React SPA": are you using the SPA Editor feature of AEM? There I would wonder if this happens.

Thus you likely have a standard component, which is using React to render. And in that case I wonder why the mentioned examples cannot are not working.

For AEM your component is not special in any way. Have you tried with a very rudimentary, non-React component? Does it work there?

Jörg

Answers (2)

Answers (2)

Jörg_Hoh

Employee

30-10-2019

Hi,

When you are using the SPA editor, you should have a full SPA without AEM rendering any markup; instead you should just consume JSON from AEM.

Or do I misunderstand your approach?

regards,

Jörg

satishak9342628

30-10-2019

Yes, I am using the SPA Editor feature of AEM with React components. Followed the WKND AEM react SPA tutorial and added a couple of custom react components. I see these extra DIV in the Preview and react app rendered pages' source as well.

Non-react components work as expected with the fixes mentioned in the links.