Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When SPA is enabled Web Components get loaded twice #1225

Open
christopher1986 opened this issue Jul 10, 2024 · 0 comments
Open

When SPA is enabled Web Components get loaded twice #1225

christopher1986 opened this issue Jul 10, 2024 · 0 comments

Comments

@christopher1986
Copy link

christopher1986 commented Jul 10, 2024

When SPA (Liferay + Senna.js) is enabled JavaScript code will get rendered twice. With regards to React this means the component and any code inside useEffect(() => {}, []); will be executed twice. With regards to fetch calls this is (somewhat) problematic.

A possible solution provided by the following Liferay article is to use Liferay.on('SPAReady', () => {}); which would prevent the code from being executed twice.

I am wondering if the Liferay Frontend Infrastructure has any other possible solution that would prevent a React component from being rendered twice? Maybe the solution provided by the Liferay article is the way to go but I would appreciate if somebody with more Liferay frontend knowledge could confirm that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant