From 3ae33d1fab903737a8aaa1a5de9656ed7271ed7f Mon Sep 17 00:00:00 2001 From: Mehran Dehghanian Date: Fri, 8 Apr 2022 17:24:11 +0430 Subject: [PATCH] Add 'FocusBlur tab detection' --- FocusBlur-tab-detection.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 FocusBlur-tab-detection.md diff --git a/FocusBlur-tab-detection.md b/FocusBlur-tab-detection.md new file mode 100644 index 0000000..52ca52a --- /dev/null +++ b/FocusBlur-tab-detection.md @@ -0,0 +1,15 @@ +Detect tab change in react, class base: + +``` +componentDidMount() { + window.addEventListener("focus", this.onFocus) +} + +componentWillUnmount() { + window.removeEventListener("focus", this.onFocus) +} + +onFocus = () => { + // +} +``` \ No newline at end of file