Skip to content

Commit

Permalink
Make object properties in NativeModules configurable.
Browse files Browse the repository at this point in the history
Summary:In Jest, we sometimes wipe away the (partial) state of the world. I noticed that when we run the NativeModules file twice, it throws. Because Jest implicitly throws out the state, it isn't obvious what exactly is going on.

I figured I'll fix this in react-native directly as I don't see a reason why those fields shouldn't be configurable. This shouldn't have any negative impact on react-native apps themselves.

cc ide bestander tadeuzagallo davidaurelio
Closes facebook#6914

Differential Revision: D3162561

Pulled By: cpojer

fb-gh-sync-id: d3418ec210278a44f8ad325f7e9e01872b4877d1
fbshipit-source-id: d3418ec210278a44f8ad325f7e9e01872b4877d1
  • Loading branch information
cpojer authored and Facebook Github Bot 9 committed Apr 11, 2016
1 parent 893e9e3 commit 838cc48
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Object.keys(RemoteModules).forEach((moduleName) => {
const NativeModules = {};
Object.keys(RemoteModules).forEach((moduleName) => {
Object.defineProperty(NativeModules, moduleName, {
configurable: true,
enumerable: true,
get: () => {
let module = RemoteModules[moduleName];
Expand Down Expand Up @@ -71,6 +72,7 @@ UIManager && Object.keys(UIManager).forEach(viewName => {
let constants;
/* $FlowFixMe - nice try. Flow doesn't like getters */
Object.defineProperty(viewConfig, 'Constants', {
configurable: true,
enumerable: true,
get: () => {
if (constants) {
Expand All @@ -90,6 +92,7 @@ UIManager && Object.keys(UIManager).forEach(viewName => {
let commands;
/* $FlowFixMe - nice try. Flow doesn't like getters */
Object.defineProperty(viewConfig, 'Commands', {
configurable: true,
enumerable: true,
get: () => {
if (commands) {
Expand Down

0 comments on commit 838cc48

Please sign in to comment.