@samitouri / QOS-React-2 / commits / 831fd6940e

Sync RN downstream fix (#9637)

Dan Abramov committed May 9, 2017 at 20:29 UTC 831fd6940ed65c390e8ef1965532add97802cca8
1 file changed +16 -4
src/renderers/native/NativeMethodsMixinUtils.js
+16 -4
@@ -57,12 +57,24 @@ export interface NativeMethodsInterface {
57 */
58 function mountSafeCallback(context: any, callback: ?Function): any {
59 return function() {
60 - if (
61 - !callback ||
62 - (typeof context.isMounted === 'function' && !context.isMounted())
63 - ) {
60 + if (!callback) {
61 return undefined;
62 }
63 + if (typeof context.__isMounted === 'boolean') {
64 + // TODO(gaearon): this is gross and should be removed.
65 + // It is currently necessary because View uses createClass,
66 + // and so any measure() calls on View (which are done by React
67 + // DevTools) trigger the isMounted() deprecation warning.
68 + if (!context.__isMounted) {
69 + return undefined;
70 + }
71 + // The else branch is important so that we don't
72 + // trigger the deprecation warning by calling isMounted.
73 + } else if (typeof context.isMounted === 'function') {
74 + if (!context.isMounted()) {
75 + return undefined;
76 + }
77 + }
78 return callback.apply(context, arguments);
79 };
80 }