-
Notifications
You must be signed in to change notification settings - Fork 113
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
Different variants on server and client #18
Comments
Has the same problem |
Same problem here |
got same problem even though I have set |
alexeyMohnatkin@e2f338b |
@alexeyMohnatkin thanks man, this work for now. You should make a PR for this. This issue really help isomorphic app. |
@alexeyMohnatkin I guess in my end this error still happen even using your patch. |
@diondirza can you create sample project? |
@alexeyMohnatkin thanks so much for giving it a shot! Do you mind creating a pull request with whatever you have? We can work together to make it work 😄 |
@alexeyMohnatkin sorry for late reply, been very busy this week. You can reproduce this error on my repo branch here. You need to retry several times with different browser or incognito mode to be able to reproduce the error. |
@peterpme Very glad to have this repo maintainer back. Do you able to update this repo so it supports latest react version? If you have time to look at my sample repo branch too, there is also a bug in server rendering about this
Thoughts? |
@diondirza I don't see any problems with variants. What behaviour do you expect? |
@peterpme #24 |
@diondirza try to rename Experiment 'menu' ;) |
@alexeyMohnatkin what's the problem with my experiment name? |
Sorry, I haven't noticed that you use emitter.defineVariants(). This function causes the bug. |
Actually it's your mistake. You call defineVariants before your app is rendered. Call it in DemoApp/index.js. |
@alexeyMohnatkin I have tried to remove that function in prod app, yet still facing it right now. I think it doesn't make sense that function cause the issue instead of on function that decides what variant to be rendered. Anyway thanks for your help. |
Any progress guys? |
@durk0 can you fork and create a test case that reproduces the issue? |
updated tests in pr |
can anybody merge pull request? |
pr is merged but I still have the same issue. |
FWIW, I wrote a wrapper component to make sure my experiment only gets rendered client-side, so I can use this package in Gatsby. Otherwise I was seeing a flash of one variant (whichever one was chosen when Gatsby pre-built the page), and then to another (whichever ended up getting chosen when rendered in the browser). Here it is:
|
Server renders variant A, but client script can show variant B after rerender.
Also server always returns only one variant until restart. I think it happens because on first render server calls emitter.setActiveVariant and then always get this value even if there's another userIdentifier.
The solution is to check userIdentifier before calling emitter.getActiveVariant in getLocalStorageValue() in Experiment component.
The text was updated successfully, but these errors were encountered: