SSR - Use Only component cause generation different HTML on server and client
See original GitHub issueWhat:
When using a component Only server HTML may differ from generated on client with warning:
Warning: Expected server HTML to contain a matching <div> in <div>.
Environment:
- node vesrion:
10.15.0
- npm version:
6.4.1
- atomic-layout version:
0.6.2
Steps to reproduce:
Steps to reproduce the behavior:
Create component on server with such composition:
<Composition
template={templateMobile}
templateMd={templateTablet}
templateLg={templateMobile}
templateColsMdOnly='minmax(100px, 1fr) 1fr'
padding={15}
gutter={15}
gutterLg={25}
>
{({ Thumbnail, Heading, Actions }) => (
<>
<Thumbnail>
Thumbnail
</Thumbnail>
<Heading>
Heading
</Heading>
<Actions>
<Only from='md' marginRight={10}>
Button
</Only>
Actions
</Actions>
</>
)}
</Composition>
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:22 (16 by maintainers)
Top Results From Across the Web
Server Side Rendering the right way | by José Manuel Aguirre
SSR : The process where a user asks the server for some url, for example: https://www.mywebsite.com/how-to-ssr and the server responds with an ...
Read more >Client-side vs. server-side rendering: why it's not all black and ...
Server -side rendering is the most common method for displaying information onto the screen. It works by converting HTML files in the server...
Read more >Web Components in Server-Side Rendered (SSR) and Static ...
Static-Site Generation (SSG) - A build tool generates static HTML ... to the component's innerHTML into a separate module, the server (or ...
Read more >Server-Side Rendering (SSR) - Vue.js
However, it is also possible to render the same components into HTML ... Static Site Generation (SSG), also referred to as pre-rendering, is...
Read more >How to use client-side only packages with SSR in Gatsby and ...
This is how server-side rendering works: the server we requested the page from executes all the code in a node server: your browser...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
According to our discussion I have set the default value for conditional rendering to be
false
. This means the conditional content will not be rendered on a server-side, and will not be rendered initially on the client-side as well (to retain proper nodes hydration). AfterOnly
component mounting it will re-match the current media query, and re-render the conditional content in case a match occurs.Published under https://github.com/kettanaito/atomic-layout/releases/tag/0.7.1.
I would be thankful if you could test this behavior in your projects and let me know. Thank you so much for this discussion, @lokhmakov, @bitttttten!
@bitttttten Yep, for client dependent code like
pixi.js
oratomic-layout/Only
we using dynamic import and all works fine, like: