remove deprecated findDOMNode
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
// Context Menu: popup/dropdown menu.
|
// Context Menu: popup/dropdown menu.
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
|
||||||
import { injectIntl, defineMessages } from 'react-intl';
|
import { injectIntl, defineMessages } from 'react-intl';
|
||||||
|
|
||||||
import { REM_SIZE } from '../config.js';
|
import { REM_SIZE } from '../config.js';
|
||||||
@@ -109,6 +108,8 @@ class ContextMenu extends React.Component {
|
|||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
|
this.selfRef = React.createRef();
|
||||||
|
|
||||||
const {formatMessage} = props.intl;
|
const {formatMessage} = props.intl;
|
||||||
|
|
||||||
this.handlePageClick = this.handlePageClick.bind(this);
|
this.handlePageClick = this.handlePageClick.bind(this);
|
||||||
@@ -318,7 +319,7 @@ class ContextMenu extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handlePageClick(e) {
|
handlePageClick(e) {
|
||||||
if (ReactDOM.findDOMNode(this).contains(e.target)) {
|
if (this.selfRef.contains(e.target)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -445,7 +446,7 @@ class ContextMenu extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ul className="menu" style={position}>
|
<ul className="menu" style={position} ref={this.selfRef}>
|
||||||
{menu}
|
{menu}
|
||||||
</ul>
|
</ul>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user