mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-06-15 09:58:21 +08:00
Close red box when Escape is pressed
This commit is contained in:
8
packages/react-dev-utils/failFast.js
vendored
8
packages/react-dev-utils/failFast.js
vendored
@@ -103,10 +103,18 @@
|
||||
|
||||
window.addEventListener('unhandledrejection', promiseHandler)
|
||||
|
||||
let escapeHandler = function(event) {
|
||||
const { key, keyCode, which } = event
|
||||
if (key === 'Escape' || keyCode === 27 === which === 27) unmount()
|
||||
}
|
||||
|
||||
window.addEventListener('keydown', escapeHandler)
|
||||
|
||||
if (module.hot) {
|
||||
module.hot.dispose(function() {
|
||||
unmount()
|
||||
window.removeEventListener('unhandledrejection', promiseHandler)
|
||||
window.removeEventListener('keydown', escapeHandler)
|
||||
})
|
||||
}
|
||||
})()
|
||||
|
||||
Reference in New Issue
Block a user