Question about layout head and side effect in library #74741
Unanswered
ivanblinov2k17
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
Hi,
I'm a developer for component ui library and we are facing quite strange problem
After our latest release theming mechanism stopped working.
Project structure:
default next project
app/layout:
app/page
node_modules/our-lib/component
node_modules/our-lib/themes
testing is done in dev version
In short, in our themes module we have side effect function init(), which parses head of current document (if code is run on the client side) for some links, and then uses it
We know, that in general it's maybe a bad idea to use side effects and we look into refactoring, but that's not the point
In previous release, first the head links were attached to DOM, and then our init function was called
Now, the order is reversed, and init is called before attaching links to DOM
Callstack for init() function is completely identical for both current and previous release
There is only one async operation in callstack, when webpack loads the module with mode == 'eager'
We haven't made any significant changes in theme module, nor in component module. But there were some structural changes, reorganizing some imports, etc. in other modules
I'm asking for some general insights on the lifecycle of how the layout is rendered, when the markup is hydrated and loaded/compared with server layout, maybe some ideas on what could lead to this issue. Thanks in advance
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions