-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat: Export getSearchParam and update login fields based on it #334
Conversation
Visit the preview URL for this PR (updated for commit c32caf6): https://ccv-honeycomb--pr334-ref-urlsearchparams-yo2eh8ak.web.app (expires Wed, 13 Dec 2023 14:57:50 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 4ace1dcea913a952d2a1af84b94a4421bf36e610 |
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.
Some questions ~
src/App/App.jsx
Outdated
if (maybeStudyID != null) setStudyID(maybeStudyID); | ||
if (maybeParticipantID != null) setParticipantID(maybeParticipantID); |
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.
Strict inequality?
if (maybeStudyID != null) setStudyID(maybeStudyID); | |
if (maybeParticipantID != null) setParticipantID(maybeParticipantID); | |
if (maybeStudyID !== null) setStudyID(maybeStudyID); | |
if (maybeParticipantID !== null) setParticipantID(maybeParticipantID); |
// Update local participantID if it changes upstream | ||
useEffect(() => { | ||
setParticipantID(initialParticipantID); | ||
}, [initialParticipantID]); | ||
|
||
// Update local studyID if it changes upstream | ||
useEffect(() => { | ||
setStudyID(initialStudyID); | ||
}, [initialStudyID]); | ||
|
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.
Why would it change upstream?
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 query parameters weren't auto-filling without these useEffect
. I think it's because the state in App.jsx
wasn't being set on the first render. I don't imagine folks will change the search parameters but if they do it will change the login fields which I think is nice
The login page is now automatically filled out if
studyID
andparticipantID
are in the URLSearchParamsgetQueryVariable
asgetSearchParam
getSearchParam
is now exported and used to readstudyID
andparticipantID
from the URLSearchParams<Login />
generateWaitSet
function as it's unusedcloses #199