Skip to content

Commit

Permalink
Remove UNSAFE_componentWillMount lifecycle methods (jaegertracing#611)
Browse files Browse the repository at this point in the history
Refactor components to no longer use UNSAFE_componentWillMount methods adhering to current React best practices.

Signed-off-by: Tim Klever <[email protected]>
Signed-off-by: vvvprabhakar <[email protected]>
  • Loading branch information
tklever authored Aug 15, 2020
1 parent b94b7a1 commit b63eba6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ export default class DependencyForceGraph extends Component {
};
}

// eslint-disable-next-line camelcase
UNSAFE_componentWillMount() {
componentDidMount() {
this.onResize();
this.debouncedResize = debounce((...args) => this.onResize(...args), 50);
window.addEventListener('resize', this.debouncedResize);
Expand Down
3 changes: 1 addition & 2 deletions packages/jaeger-ui/src/components/DependencyGraph/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ export class DependencyGraphPageImpl extends Component {
};
}

// eslint-disable-next-line camelcase
UNSAFE_componentWillMount() {
componentDidMount() {
this.props.fetchDependencies();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,12 @@ type State = {
* Used to render the detail column.
*/
export default class DetailTableData extends Component<Props, State> {
// eslint-disable-next-line camelcase
UNSAFE_componentWillMount() {
constructor(props: Readonly<Props>) {
super(props);
const element = this.props.values.map(item => {
return { uid: _.uniqueId('id'), value: item };
});
this.setState(prevState => {
return {
...prevState,
element,
};
});
this.state = { element };
}

render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,13 @@ type State = {
* Used to render the main column.
*/
export default class MainTableData extends Component<Props, State> {
// eslint-disable-next-line camelcase
UNSAFE_componentWillMount() {
constructor(props: Readonly<Props>) {
super(props);
const element = this.props.values.map(item => {
return { uid: _.uniqueId('id'), value: item };
});

this.setState(prevState => {
return {
...prevState,
element,
};
});
this.state = { element };
}

render() {
Expand Down

0 comments on commit b63eba6

Please sign in to comment.