Fixed crash when forwarding already existing property from ReactNativeInternal to ReactNative

Reviewed By: ericvicenti

Differential Revision: D4843917

fbshipit-source-id: 6cdbac28d8a220a6ac289e8b98d9d50eca35e176
This commit is contained in:
Oleg Lokhvitsky 2017-04-06 13:43:54 -07:00 committed by Facebook Github Bot
parent 39eb090906
commit ea30aa0fa4
1 changed files with 8 additions and 0 deletions

View File

@ -150,6 +150,14 @@ function applyForwarding(key) {
);
return;
}
if (ReactNative.hasOwnProperty(key)) {
// WARNING! ReactNative has read-only keys. So, if ReactNativeInternal
// has any duplicate key that ReactNative already has, this assignment
// would fail with "Attempted to assign to readonly property."
// So, if the key already exists on ReactNative, we assume that it's the
// correct module and skip re-assigning it.
return;
}
ReactNative[key] = ReactNativeInternal[key];
}
for (const key in ReactNativeInternal) {