NextJS Rendering
See original GitHub issueTable of Contents
- Expected Behavior
- Current Behavior
- Possible Solution
- Steps to Reproduce (for bugs)
- Context
- Your Environment
Expected Behavior
The Experiment should render one variation and it should be displayed properly
Setup:
<Experiment name="An Experiment" userIdentifier={this.props.sessionId}> - sessionId comes from express-session
<Variant name="Variation A">
<div>
{children} - children here represent actual elements not like a parent Component
</div>
</Variant>
<Variant name="Variation B">
<div>
{children} - children here represent actual elements not like a parent Component
</div>
</Variant>
</Experiment>
Current Behavior
The Experiment does render a variation but it does not render the proper elements and its children.
Outcome:
{/* Rendered Properly */}
<div className="class">
<p className="class-p">
Hello P
</p>
<p className="class-pd">
Hello PD
</p>
</div>
{/* Current Results */}
<div className="class">
<p className="class-p">
Hello PD
</p>
<p className="class-pd">
Hello P
</p>
</div>
Possible Solution
Steps to Reproduce (for bugs)
- Start a new nextjs project
- Make a new Experiment in a page
- Add the
sessionIdfrom express-session to the ExperimentuserIdentifierprop - See the results
Context
I can not show different variants properly if the rendering keeps breaking.
Your Environment
- Version used: 2.3.0
- Browser Name and version: Chrome 86.0.4240.75 or Firefox 81
- Operating System and version (desktop or mobile): Manjaro
- Link to your project: Can not provide.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:9 (1 by maintainers)
Top Results From Across the Web
What is Rendering? - How Next.js Works
With Next.js, three types of rendering methods are available: Server-Side Rendering, Static Site Generation, and Client-Side Rendering. Pre-Rendering.
Read more >Basic Features: Pages - Next.js
Next.js has two forms of pre-rendering: Static Generation and Server-side Rendering. The difference is in when it generates the HTML for a page....
Read more >Pre-rendering and Data Fetching | Learn Next.js
Next.js ' pre-rendering feature. The two forms of pre-rendering: Static Generation and Server-side Rendering. Static Generation with data, and without data.
Read more >Rendering Strategies - Rendering and Ranking | Learn Next.js
Client Side Rendering (CSR). Client-Side Rendering allows developers to make their websites entirely rendered in the browser with JavaScript. On initial page ...
Read more >Two Forms of Pre-rendering - Pre-rendering and Data Fetching
Next.js has two forms of pre-rendering: Static Generation and Server-side Rendering. The difference is in when it generates the HTML for a page....
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 Free
Top 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

Solve it the same way. Thank you @gregegan it was the solution to use dynamic import
I created an example here: https://github.com/marvelapp/react-ab-test/tree/master/examples/next with server side rendering in NextJS. The user identifier is just a UUID stored in the current session: https://github.com/marvelapp/react-ab-test/blob/f48b4a50daf32e9facb5ae6d2588a8288d384eea/examples/next/src/pages/index.js#L31-L43 Let me know if that helps!