-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[docs] Fix /production-error crash #25839
Conversation
const [rating, setRating] = React.useState(); | ||
const [comment, setComment] = React.useState(''); | ||
const [commentOpen, setCommentOpen] = React.useState(false); | ||
const [snackbarOpen, setSnackbarOpen] = React.useState(false); | ||
const [snackbarMessage, setSnackbarMessage] = React.useState(false); | ||
const inputRef = React.useRef(); | ||
const pageList = flattenPages(pages); | ||
const currentPageNum = findIndex(pageList, (page) => page.pathname === activePage?.pathname); | ||
const currentPage = pageList[currentPageNum]; |
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.
If activePage
was not null
then currentPage === activePage
i.e. currentPage
was redundant.
* If a page should be excluded from this order, set `order: false`. | ||
* You want to set `ordered: false` if you don't want the page to appear in an ordered list e.g. for previous/next page navigation. | ||
*/ | ||
ordered?: boolean; |
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.
The wording is a bit rough. displayNav
also works considering the disableDrawer
wording. Maybe just keep the original word but keep the description?
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.
No regressions spotted
Fixes a crash in /production-error/ (current
next
): https://deploy-preview-25839--material-ui.netlify.app/production-error/The previous logic for creating the prev/next page navigation relied on the current order of pages. However, one could imagine that we later extend the pages to
Now
/a/new/page
would not be considered the next page after/an/existing/page
. With this PR users will be able to navigate from/an/existing/page
to/a/new/page
with thenext
button.The change required for this seems quite big but should be easier to follow and more robust against various positions of
activePage
. For example,activePage
being the last entry inpages
would lead to a crash. We didn't encounter this crash because of the current order ofpages
.