Skip to content
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

Allow dismissing full refresh warning for session #33868

Merged
merged 6 commits into from Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/next/client/dev/error-overlay/hot-dev-client.js
Expand Up @@ -350,5 +350,6 @@ function hasAlreadyWarnedAboutFullRefresh() {
}

function clearFullRefreshStorage() {
sessionStorage.removeItem(FULL_REFRESH_STORAGE_KEY)
if (sessionStorage.getItem(FULL_REFRESH_STORAGE_KEY) !== 'ignore')
sessionStorage.removeItem(FULL_REFRESH_STORAGE_KEY)
}
2 changes: 1 addition & 1 deletion packages/next/compiled/@next/react-dev-overlay/client.js

Large diffs are not rendered by default.

Expand Up @@ -12,11 +12,19 @@ import { noop as css } from '../helpers/noop-template'

export type FullRefreshWarningProps = { reason: string | null }

const FULL_REFRESH_STORAGE_KEY = '_has_warned_about_full_refresh'

export const FullRefreshWarning: React.FC<FullRefreshWarningProps> =
function FullRefreshWarning({ reason }) {
const reload = React.useCallback(() => {
window.location.reload()
}, [])
const change = React.useCallback((e) => {
sessionStorage.setItem(
FULL_REFRESH_STORAGE_KEY,
e.target.checked ? 'ignore' : 'true'
)
}, [])

return (
<Overlay fixed>
Expand All @@ -42,6 +50,10 @@ export const FullRefreshWarning: React.FC<FullRefreshWarningProps> =
</a>
.
</p>
<label>
<input type="checkbox" onChange={change} /> Don't show again
ijjk marked this conversation as resolved.
Show resolved Hide resolved
for session
</label>
<button onClick={reload}>Reload</button>
</footer>
</DialogBody>
Expand Down