Remove all usages of UNSAFE_* React methods (#9583)
This commit is contained in:
parent
38dbe8ed33
commit
590b845f3f
33 changed files with 585 additions and 413 deletions
|
@ -22,6 +22,7 @@ import AccessibleButton, { ButtonEvent } from './AccessibleButton';
|
|||
import { _t } from '../../../languageHandler';
|
||||
import { getKeyBindingsManager } from "../../../KeyBindingsManager";
|
||||
import { KeyBindingAction } from "../../../accessibility/KeyboardShortcuts";
|
||||
import { objectHasDiff } from "../../../utils/objects";
|
||||
|
||||
interface IMenuOptionProps {
|
||||
children: ReactElement;
|
||||
|
@ -136,20 +137,18 @@ export default class Dropdown extends React.Component<DropdownProps, IState> {
|
|||
document.addEventListener('click', this.onDocumentClick, false);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
document.removeEventListener('click', this.onDocumentClick, false);
|
||||
public componentDidUpdate(prevProps: Readonly<DropdownProps>) {
|
||||
if (objectHasDiff(this.props, prevProps) && this.props.children?.length) {
|
||||
this.reindexChildren(this.props.children);
|
||||
const firstChild = this.props.children[0];
|
||||
this.setState({
|
||||
highlightedOption: String(firstChild?.key) ?? null,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: [REACT-WARNING] Replace with appropriate lifecycle event
|
||||
UNSAFE_componentWillReceiveProps(nextProps) { // eslint-disable-line
|
||||
if (!nextProps.children || nextProps.children.length === 0) {
|
||||
return;
|
||||
}
|
||||
this.reindexChildren(nextProps.children);
|
||||
const firstChild = nextProps.children[0];
|
||||
this.setState({
|
||||
highlightedOption: firstChild ? firstChild.key : null,
|
||||
});
|
||||
componentWillUnmount() {
|
||||
document.removeEventListener('click', this.onDocumentClick, false);
|
||||
}
|
||||
|
||||
private reindexChildren(children: ReactElement[]): void {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue