Skip to content

Commit a3ae31e

Browse files
committed
Close red box when Escape is pressed
1 parent c742848 commit a3ae31e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/react-dev-utils/failFast.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,18 @@
103103

104104
window.addEventListener('unhandledrejection', promiseHandler)
105105

106+
let escapeHandler = function(event) {
107+
const { key, keyCode, which } = event
108+
if (key === 'Escape' || keyCode === 27 === which === 27) unmount()
109+
}
110+
111+
window.addEventListener('keydown', escapeHandler)
112+
106113
if (module.hot) {
107114
module.hot.dispose(function() {
108115
unmount()
109116
window.removeEventListener('unhandledrejection', promiseHandler)
117+
window.removeEventListener('keydown', escapeHandler)
110118
})
111119
}
112120
})()

0 commit comments

Comments
 (0)