Skip to content
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

Merged
merged 4 commits into from
Sep 16, 2024

Conversation

alfetopito
Copy link
Collaborator

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

  1. Use this PR's deployment URL into Safe UI. Might require running a local version of the Safe

Copy link

vercel bot commented Sep 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
cosmos ✅ Ready (Inspect) Visit Preview Sep 13, 2024 6:01pm
cowfi ✅ Ready (Inspect) Visit Preview Sep 13, 2024 6:01pm
explorer-dev ✅ Ready (Inspect) Visit Preview Sep 13, 2024 6:01pm
swap-dev ✅ Ready (Inspect) Visit Preview Sep 13, 2024 6:01pm
widget-configurator ✅ Ready (Inspect) Visit Preview Sep 13, 2024 6:01pm


useEffect(() => {
if (!state?.tradeType) return
if (isFirstLoad.current && !!state) {
Copy link
Collaborator

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?

Copy link
Collaborator Author

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 🤷

Copy link
Collaborator

@shoom3301 shoom3301 left a 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.

Copy link

@elena-zh elena-zh left a 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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tokens are flickering in the widget
3 participants