You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently unverified modal and guest modal is commonly used but takes up a lot of boilerplate
Boilerplate
const{
isSuccess,
isPending,
open,
content,
setContent,
setModalAlert,
reset,}=useModal()consttriggerUnverifiedModal=useCallback(()=>{open()setModalAlert(false)setContent('unverified')},[open,setModalAlert,setContent])constgoToCreate=()=>{if(isVerified){history.push(`${url}/new`)}elseif(isAuthenticated){triggerUnverifiedModal()}else{open()setContent('login','You must be logged in to create a recipe')}}useEffect(()=>{if(!isPending&&isSuccess&&content==='login'&&isVerified){// need to clear modal settings so that going back// to this page doesn't retrigger this effectreset()history.push(`${url}/new`)}},[isPending,isSuccess,content,isVerified,url,history,reset])
Changes we want
make it so you can just get const { triggerUnverifiedModal, triggerGuestModal } = useModal() and not have to reconstruct the functions each time
investigate if we can simplify the isSuccess status to not have to do so many low level checks — content check & reset()
Example of complex isSuccess status check
useEffect(()=>{if(!isPending&&isSuccess&&content==='login'&&isVerified){// need to clear modal settings so that going back// to this page doesn't retrigger this effectreset()history.push(`${url}/new`)}},[isPending,isSuccess,content,isVerified,url,history,reset])
The text was updated successfully, but these errors were encountered:
pattruong
added
dx
Developer Experience: improves our ability to work or collaborate
refactor
Clean up and/or improve past implementations
labels
Apr 13, 2021
Overview
Currently unverified modal and guest modal is commonly used but takes up a lot of boilerplate
Boilerplate
Changes we want
const { triggerUnverifiedModal, triggerGuestModal } = useModal()
and not have to reconstruct the functions each timeisSuccess
status to not have to do so many low level checks —content
check &reset()
isSuccess
status checkThe text was updated successfully, but these errors were encountered: