1 | import React from 'react';
|
2 | var unsafeLifecyclesPolyfill = function unsafeLifecyclesPolyfill(Component) {
|
3 | var prototype = Component.prototype;
|
4 | if (!prototype || !prototype.isReactComponent) {
|
5 | throw new Error('Can only polyfill class components');
|
6 | }
|
7 |
|
8 |
|
9 | if (typeof prototype.componentWillReceiveProps !== 'function') {
|
10 | return Component;
|
11 | }
|
12 |
|
13 |
|
14 |
|
15 | if (!React.Profiler) {
|
16 | return Component;
|
17 | }
|
18 |
|
19 |
|
20 | prototype.UNSAFE_componentWillReceiveProps = prototype.componentWillReceiveProps;
|
21 | delete prototype.componentWillReceiveProps;
|
22 | return Component;
|
23 | };
|
24 | export default unsafeLifecyclesPolyfill; |
\ | No newline at end of file |