-
Notifications
You must be signed in to change notification settings - Fork 832
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
[Calendar] Remove promise based loading in favor of loading
prop
#1829
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/mui-org/material-ui-pickers/qp2h2p173 |
Test summaryRun details
View run in Cypress Dashboard ➡️ This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
}) | ||
.then(res => res.json()) | ||
.then(({ daysToHighlight }) => { | ||
setSelectedDays(daysToHighlight); |
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.
What if the component unmounts before the request resolves? I believe the set state call will warn/throw. The solution proposed in could be applied here too mui/mui-x#5 (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.
We are saving abort controller. So needs to make an effect that will abort request on unmount. thanks
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's one way to solve this. I have no idea what's the best approach. I guess it's good enough, no need to look further 👍
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.
Interesting, but I think that this solution has one giant pitfall – it doesn't abort the request.
Probably if we want to support IE we must not use fetch and promises at all.
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.
Can requests be aborted? I mean, does it change something at the network layer?
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.
Nice :)
This PR closes #1454
User facing changes
Breaking changes
Promise
from theonMonthChangeProp
to render spinner in the component. From now on useloading
prop to renderLoadingComponent
in the calendar.loadingIndicator
toLoadingComponent
Features
loading
prop that will render loading placeholder while data is loading.CalendarSkeleton
component that can be used to achieve first-class UX experience for preloading data on month change: