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

If you nest two Solid islands into each other, the nested one is mounted twice #6263

Closed
1 task
alexander-lozovsky opened this issue Feb 16, 2023 · 9 comments
Closed
1 task
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority)

Comments

@alexander-lozovsky
Copy link

What version of astro are you using?

2.0.12

Are you using an SSR adapter? If so, which one?

No

What package manager are you using?

npm

What operating system are you using?

Mac

Describe the Bug

When you render two Solid islands nested into each other, the nested one is mounted twice.

So in case you have something like this:

<Wrapper client:idle>
  <NestedComponent client:idle>
    <p>Hello world</p>
  </NestedComponent>
</Wrapper>

NestedComponent runs twice in the browser, which means that if you run some logic inside onMount, it runs twice.

See the attached stackblitz: click "Open in New Tab" and observe "NestedComponent" logged twice in the console

Same composition with React components works as expected https://stackblitz.com/edit/github-tgt7ck?file=src/pages/index.astro

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-gcp42c?file=package.json

Participation

  • I am willing to submit a pull request for this issue.
@idiglove
Copy link

image
I don't see "Nested Component" being logged twice

@alexander-lozovsky
Copy link
Author

@idiglove you're looking at the dev server logs, please check the browser logs

image
image

@SerekKiri
Copy link
Contributor

Problem might be with a fallback to load event from requestIdleCallback as that what astro does -> https://docs.astro.build/en/reference/directives-reference/#clientidle

window.requestIdleCallback is not supported on safari
image

Question though as there is no load being used but a setTimeout instead if I'm looking into proper places.
image
image

I might dig a bit 🤔

@SerekKiri
Copy link
Contributor

Also docs update for client:idle was 10 months ago and 8 months ago for requestIdleCallback so probably docs should be updated as well 👍🏼
image

@SerekKiri
Copy link
Contributor

@alexander-lozovsky did you test that in a production mode?

@alexander-lozovsky
Copy link
Author

@SerekKiri yes, it happens in both SSR and SSG builds

@matthewp matthewp added the - P4: important Violate documented behavior or significantly impacts performance (priority) label Mar 24, 2023
@SerekKiri
Copy link
Contributor

@alexander-lozovsky could you check if your project will work properly with changes added by @matthewp in the PR mentioned above?

@bluwy
Copy link
Member

bluwy commented Jun 29, 2023

I haven't tested yet, but #7370 might also help with this.

@bluwy
Copy link
Member

bluwy commented Jul 5, 2023

I ran the repro and updated Astro to latest and it seems to be fixed now.

@bluwy bluwy closed this as completed Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority)
Projects
None yet
Development

No branches or pull requests

5 participants