Skip to content

Commit

Permalink
Allow dismissing full refresh warning for session (#33868)
Browse files Browse the repository at this point in the history
x-ref: #31827
x-ref: #34212

![image](https://user-images.githubusercontent.com/1365881/151994766-b9afb349-1a9a-4220-9387-de10165e34e3.png)




## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
  • Loading branch information
sokra and ijjk committed Feb 14, 2022
1 parent 5402f09 commit c20e829
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
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
for session
</label>
<button onClick={reload}>Reload</button>
</footer>
</DialogBody>
Expand Down

0 comments on commit c20e829

Please sign in to comment.