-
Notifications
You must be signed in to change notification settings - Fork 89
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
fix(widget): widget tokens flickering #4883
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
||
useEffect(() => { | ||
if (!state?.tradeType) return | ||
if (isFirstLoad.current && !!state) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this is a key change to break the loop.
But what the point of creating tradeStateFromUrlAtom
? Probably you did it to cache the tradeStateFromUrl
value, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct! I thought at first that could be related, since the hook is included in multiple places causing it to be constantly re-evaluated. Decided to add since it was already done 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Locally the issue is not reproducible anymore, but haven't tests too deep.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how to test this. With a preview link it works good, the widget preview link cannot be opened. Approving, and will retest all these changes once they are in Develop.
2f8815d
to
bf80037
Compare
Summary
Fixes #4879
Due to a race condition between parent widget props and inner app state, the tokens endup flickering non-stop.
This change makes sure on the first load, the app refrain from sending the state update event.
The side effect is that the state previously set in the widget will be always cleared in favor of the param coming from the parent widget - but only if they listen to the widget events.
To Test