From 5a5eb5425f2d5ee1e7f15d923b580f7d0027530e Mon Sep 17 00:00:00 2001 From: Nicolas Gallagher Date: Thu, 15 Jun 2017 19:30:18 -0700 Subject: [PATCH] Allow component styles to be editable in React Dev Tools --- src/apis/StyleSheet/index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/apis/StyleSheet/index.js b/src/apis/StyleSheet/index.js index ad92aa2a..bacaf6a0 100644 --- a/src/apis/StyleSheet/index.js +++ b/src/apis/StyleSheet/index.js @@ -1,6 +1,14 @@ import flattenStyle from './flattenStyle'; import StyleRegistry from './registry'; +// allow component styles to be editable in React Dev Tools +if (process.env.NODE_ENV !== 'production') { + const { canUseDOM } = require('fbjs/lib/ExecutionEnvironment'); + if (canUseDOM && window.__REACT_DEVTOOLS_GLOBAL_HOOK__) { + window.__REACT_DEVTOOLS_GLOBAL_HOOK__.resolveRNStyle = flattenStyle; + } +} + const absoluteFillObject = { position: 'absolute', left: 0,