-
Notifications
You must be signed in to change notification settings - Fork 28.4k
What is your experience with shared nextJS components for different projects ? #3623
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
Comments
Sounds like either SSR isn’t setup for your CSS, or the SSR’s CSS isn’t in the head. |
The css is being loaded oke, but with with delay. |
The problem is that there's 2 versions of styled-jsx in this case. And styled-jsx uses a singleton module to keep track of the styles that are rendered on the server. Next.js v5 will allow you to customize the webpack configuration to include certain modules to be transpiled. Removing the requirement to have styled-jsx as a dependency. Which will solve this issue 👍 |
More improvements for code sharing are planned for after v5 👍 |
FYI @vanGalilea @timneutkens I've had a similar problem with |
Since Zones are already released. (Thx @arunoda and @timneutkens !!!) |
I've run into this same issue, developing a shared component library of components that use styled-jsx resulting in FOUC. Is vercel/styled-jsx#64 the solution to this problem? |
@tomaswitek Were you able to push further than this ^? How do you handle transpilation of the shared components and ensure that changes in the shared components are automatically reflected in the workspaces? |
As an update, I've worked around the FOUC from a library of shared components by exporting a "bound" version of the styled-jsx flush methods, and then in
And then in the associated
(next itself takes care of flushing and rendering all of the styled-jsx in your app proper) This is a nice way to workaround vercel/styled-jsx#64. |
Let's track this in #706 |
Hi all,
What is your experience regarding an external shared nextJS components module and it's implementation in different projects.
Basically what we have now is 2 projects that have around 80% of the same code (react components) and we would like to have the 80% code reusable in both nextJS projects (and other future projects).
We currently have an external modules using nextJS with the reusable components, which is linked with npm link to the 2 projects that using the reusable models, everything is going well besides one problem we're experiencing:
The styles of an imported reusable component (written in styled-jsx) are being loaded few seconds after the html is being loaded (so basically you see an image with no style and around 500 ms later you see that the style kicks in).
So how can you make sure there is no delay when loading the styling and would could be the problem causing it ?
And last but not least what is your experience with shared components and later reusing them in different projects ?
tnx
The text was updated successfully, but these errors were encountered: