From 29e9691fb516a92e99322a9832ceb120bb2e475e Mon Sep 17 00:00:00 2001 From: Anton Korzunov Date: Mon, 22 Apr 2019 18:28:20 +1000 Subject: [PATCH] fix: infinite loop on ref set --- src/Lock.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Lock.js b/src/Lock.js index fcdec65..7f11646 100644 --- a/src/Lock.js +++ b/src/Lock.js @@ -51,10 +51,13 @@ class FocusLock extends Component { onBlur = onBlur; - setObserveNode = observed => - this.setState({ - observed, - }); + setObserveNode = (observed) => { + if (this.state.observed !== observed) { + this.setState({ + observed, + }); + } + }; // active status is tracked outside React state isActive = false;