Skip to main content
Leela-Pavan-Kumar
Level 4
Dec 30, 2021 4:01 PM UTC

Component rendering twice in Publish Mode [SPA/REACT]

AEM React Spa components are rendering twice in publish Mode.

 

In Author Mode:

 

In Publish Mode:

Why the content is rendering twice and How to fix this issue?

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

5 replies

milind_bachani
Adobe Employee
Adobe Employee
Dec 31, 2021 10:39 AM UTC

Hi @leela-pavan-kumar ,

This possibly happens if you are using the React.StrictMode in your markup.

An ugly fix would be to snub the extra calls from en.model.json 

Reference:

https://andreasheissenberger.medium.com/react-components-render-twice-any-way-to-fix-this-91cf23961625
https://experienceleague.adobe.com/docs/experience-manager-learn/sites/spa-editor/spa-editor-helloworld-tutorial-use.html?lang=en

 

Translate
Leela-Pavan-Kumar
Level 4
Jan 3, 2022 5:36 AM UTC

Hi @milind_bachani ,

 

Thanks for the response,

 

We are not using React.StrictMode in our index.js.

 

Could you please let me know how can I snub the calls from en.model.json.

Translate
milind_bachani
Adobe Employee
Adobe Employee
Jan 5, 2022 12:45 PM UTC

Hi @leela-pavan-kumar - are you still facing the issue ?


If yes, you need to check couple of things before making changes to the model.json:
1. The publisher CRX-de does not show 2 component in your /content path
2. Please post the en.model.json response from network tab here.?
3. Try to align the component with tutorial link shared above.

We can investigate further based on the above mentioned checks.

Thanks.

Translate
Level 3
Sep 19, 2023 4:26 AM UTC

@leela-pavan-kumar were you able to resolve this? can you let me know what was done? we are also facing similar issue. feel its issue with templates.

Translate
Leela-Pavan-Kumar
Level 4
Oct 9, 2023 10:38 AM UTC

Yes, It's with SPA behaviour.

Make sure that current page URL model json is being called only if it not part of en model json. This is happening when there are two matched :path properties with the current page( one is already in en.model.json and one more call is happening to fetch the items).

Translate