Skip to content

Using lazy-loaded components in the context fails to render. #2473

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

Open
thep0y opened this issue Apr 28, 2025 · 3 comments
Open

Using lazy-loaded components in the context fails to render. #2473

thep0y opened this issue Apr 28, 2025 · 3 comments
Labels
unverified bug Bug yet to be verified

Comments

@thep0y
Copy link

thep0y commented Apr 28, 2025

Describe the bug

In the console, you can see the mounted message of the ButtonDemo component, but the ButtonDemo component itself failed to render. Meanwhile, there are no warnings or error messages in the console regarding the rendering failure of the component.

If you only start the development server without building, the ButtonDemo component can be rendered normally.

Your Example Website or App

https://github.com/thep0y/solid-context-demo

Steps to Reproduce the Bug or Issue

bun run build
cd example
bun run build
bun run preview

Expected behavior

The ButtonDemo component renders normally.

Screenshots or Videos

No response

Platform

  • OS: [Windows]
  • Browser: [Chrome]
  • Version: [135.0.7049.115]

Additional context

No response

@ryansolid
Copy link
Member

Any way to get a more minimal reproduction? This requires tracing through multiple projects to figure out where the bug is.

I made a quick playground to show Context working in a lazy component.. unless you mean in a different way? https://playground.solidjs.com/anonymous/2d6654f8-d1ee-4a7c-a079-b200b23c73d1

Maybe use something like this or a basic Stackblitz as a base.

@ryansolid ryansolid added the unverified bug Bug yet to be verified label Apr 30, 2025
@thep0y
Copy link
Author

thep0y commented May 1, 2025

I need to try.

The current reproduction steps are based on the project I wrote, and a lot of irrelevant components have already been removed.

@thep0y
Copy link
Author

thep0y commented May 1, 2025

In the reproduced component library packages, there are currently only two components. After bundling them, there might be two issues when importing the components button and toast in the example:

  • If useToast is used in ButtonDemo to get the context, it will definitely throw an error cannot find a ToastContext.
  • If useToast is not used in ButtonDemo to get the context, ButtonDemo will not be added to the DOM node, but its structure can still be printed in the console.

The most critical issue is that everything works fine in the development environment, but the above two problems only occur in the production environment.

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

No branches or pull requests

2 participants