-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
ref(sandbox): Demo Header Update & fix email localstorage #29625
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
Conversation
size-limit report
|
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.
@Neo-Zhixing It would be nice to keep that as a link but doing that would require us to make a HoC that listens for local storage changes and re-renders the child when that happens. Maybe too much work given the level of importance. But I'd still add a comment explaining why we are calling window.open this way
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 thought about listening to local storage changes but that requires us to replace localStorage.setItem which is a global change. Will add lots of maintenance overhead.
https://stackoverflow.com/questions/26974084/listen-for-changes-with-localstorage-on-the-same-window
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.
Will add comment.
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.
You can do this with a react hook, which I think we already do in some places
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.
@evanpurkhiser and which hook is that?
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 also don't know if a hook works here when a different part of the app is updating the local storage. I think this hook only works when you're changing the session storage with the setState that the hook returns in that single component.
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.
it would work if you have a state that is updated on localstorage change. You can use the storage event for that.
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.
Note: This won't work on the same page that is making the changes — it is really a way for other pages on the domain using the storage to sync any changes that are made. Pages on other domains can't access the same storage objects.
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.
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.
ew gross event. Yeah just do what you've got here. Or put it in reflux but 🤷
45f01f3 to
1dad153
Compare
This PR does three things:
URLSearchParamsfor extra query paramswindow.openforGet Startedbutton on the demo header, so we retrieve theemailfield from local storage when you click the button, instead of at page load time. This will not trigger the popup button blocker because it is triggered by an user event.