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