From a74be91b7ca9d3e3fd7a911fc9a0747e0e2d598a Mon Sep 17 00:00:00 2001 From: Nicolas Gallagher Date: Mon, 2 Jan 2017 11:27:46 -0800 Subject: [PATCH] Minor documentation changes --- docs/guides/style.md | 13 +++---------- src/apis/StyleSheet/registry.js | 15 ++++++++------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/docs/guides/style.md b/docs/guides/style.md index e5b6cb18..7d486aea 100644 --- a/docs/guides/style.md +++ b/docs/guides/style.md @@ -31,10 +31,9 @@ const styles = StyleSheet.create({ }) ``` -Using `StyleSheet.create` is optional but provides some key advantages: styles -are immutable in development, certain declarations are automatically converted -to CSS rather than applied as inline styles, and styles are only created once -for the application and not on every render. +Using `StyleSheet.create` is optional but provides the best performance +(`style` is resolved to CSS stylesheets). Avoid creating unregistered style +objects. The attribute names and values are a subset of CSS. See the `style` documentation of individual components. @@ -56,12 +55,6 @@ A common pattern is to conditionally add style based on a condition: styles.base, this.state.active && styles.active ]} /> - -// or - ``` ## Composing styles diff --git a/src/apis/StyleSheet/registry.js b/src/apis/StyleSheet/registry.js index ed0ba7d0..67411f28 100644 --- a/src/apis/StyleSheet/registry.js +++ b/src/apis/StyleSheet/registry.js @@ -68,12 +68,6 @@ const registerStyle = (id, flatStyle) => { const resolveProps = (reactNativeStyle) => { const flatStyle = flattenStyle(reactNativeStyle); - if (process.env.__REACT_NATIVE_DEBUG_ENABLED__) { - console.groupCollapsed('[render] deoptimized: resolving uncached styles'); - console.log('source style\n', reactNativeStyle); - console.log('flattened style\n', flatStyle); - } - const domStyle = createReactDOMStyle(flatStyle); const style = {}; @@ -99,7 +93,14 @@ const resolveProps = (reactNativeStyle) => { }; if (process.env.__REACT_NATIVE_DEBUG_ENABLED__) { - console.log('DOM props\n', props); + console.groupCollapsed('[StyleSheet] resolving uncached styles'); + console.log( + `Slow operation. Resolving style objects (uncached result). ` + + `Occurs on first render and when using styles not registered with "StyleSheet.create"` + ); + console.log('source => \n', reactNativeStyle); + console.log('flatten => \n', flatStyle); + console.log('resolve => \n', props); console.groupEnd(); }