Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const React = require('react');
const SomeOtherComponent = require('SomeOtherComponent');

class PMTAuthenticationFailureDialog extends React.Component<any, any> {
componentDidMount(): void {
SomeOtherComponent.mixin.componentDidMount.apply(this);
}

componentWillMount(): void {
SomeOtherComponent.mixin.componentWillMount.apply(this);
}

componentWillUnmount(): void {
SomeOtherComponent.mixin.componentWillUnmount.apply(this);
}

render() {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const React = require('react');
const SomeOtherComponent = require('SomeOtherComponent');

class PMTAuthenticationFailureDialog extends React.Component<any, any> {
componentDidMount(): void {
SomeOtherComponent.mixin.componentDidMount.apply(this);
}

UNSAFE_componentWillMount(): void {
SomeOtherComponent.mixin.UNSAFE_componentWillMount.apply(this);
}

componentWillUnmount(): void {
SomeOtherComponent.mixin.componentWillUnmount.apply(this);
}

render() {
return null;
}
}
1 change: 1 addition & 0 deletions transforms/__tests__/rename-unsafe-lifecycles-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const tests = [
'create-react-class',
'instance-methods',
'manually-calling-lifecycles',
'manually-invoked-mixin-methods',
'one-lifecycle-calls-another',
'standalone-function',
'variable-within-class-method',
Expand Down
10 changes: 3 additions & 7 deletions transforms/rename-unsafe-lifecycles.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,10 @@ export default (file, api, options) => {
};

const renameDeprecatedCallExpressions = path => {
if (!path.node.callee || !path.node.callee.property) {
return;
}

const name = path.node.callee.property.name;
const name = path.node.property.name;

if (DEPRECATED_APIS[name]) {
path.node.callee.property.name = DEPRECATED_APIS[name];
path.node.property.name = DEPRECATED_APIS[name];
hasModifications = true;
}
};
Expand All @@ -66,7 +62,7 @@ export default (file, api, options) => {

// Function calls
root
.find(j.CallExpression)
.find(j.MemberExpression)
.forEach(renameDeprecatedCallExpressions);

return hasModifications
Expand Down