Skip to content

Commit a2563c0

Browse files
author
Andrey Okonetchnikov
committed
fix: Rename this.isMounted to this._isMounted to not clash with the deprecated React method
1 parent 15649f6 commit a2563c0

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/FocusWithin.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ class FocusWithin extends React.Component {
1212
focused: false
1313
}
1414

15-
isMounted = false
16-
lastBlurEvent = null
15+
_isMounted = false
16+
_lastBlurEvent = null
1717

1818
ref = React.createRef()
1919

@@ -27,12 +27,12 @@ class FocusWithin extends React.Component {
2727
document.querySelector('body').setAttribute('tabindex', '-1')
2828
}
2929
/* Mark as mounted */
30-
this.isMounted = true
30+
this._isMounted = true
3131
}
3232

3333
componentWillUnmount() {
3434
/* Mark as unmounted */
35-
this.isMounted = false
35+
this._isMounted = false
3636

3737
/* Since the onBlur for the unmounted component will never fire, we need to cleanup here. */
3838
document.removeEventListener('focusin', this._onFocusIn)
@@ -67,9 +67,9 @@ class FocusWithin extends React.Component {
6767
*/
6868
_onFocusIn = () => {
6969
if (
70-
this.isMounted &&
71-
this.lastBlurEvent &&
72-
this.isInsideNode(this.ref.current, this.lastBlurEvent.target) &&
70+
this._isMounted &&
71+
this._lastBlurEvent &&
72+
this.isInsideNode(this.ref.current, this._lastBlurEvent.target) &&
7373
!this.isInsideNode(this.ref.current, document.activeElement)
7474
) {
7575
this.setState(
@@ -78,7 +78,7 @@ class FocusWithin extends React.Component {
7878
},
7979
() => {
8080
document.removeEventListener('focusin', this._onFocusIn)
81-
this.props.onBlur(this.lastBlurEvent)
81+
this.props.onBlur(this._lastBlurEvent)
8282
}
8383
)
8484
}
@@ -120,7 +120,7 @@ class FocusWithin extends React.Component {
120120
*/
121121
onBlur = evt => {
122122
evt.persist() // Persist the original event since it will be fired later
123-
this.lastBlurEvent = evt
123+
this._lastBlurEvent = evt
124124
}
125125

126126
/**

0 commit comments

Comments
 (0)