这应该工作:
componentDidMount() { window.addEventListener("focus", this.onFocus)}componentWilUnmount() { window.removeEventListener("focus", this.onFocus)}onFocus = () => { //}编辑:“模糊”同样适用,并且在选项卡变为隐藏状态时也应适用。
检查@Assaf的答案是否有钩子。

这应该工作:
componentDidMount() { window.addEventListener("focus", this.onFocus)}componentWilUnmount() { window.removeEventListener("focus", this.onFocus)}onFocus = () => { //}编辑:“模糊”同样适用,并且在选项卡变为隐藏状态时也应适用。
检查@Assaf的答案是否有钩子。