diff --git a/docs/guides/getting-started.md b/docs/guides/getting-started.md index f17f5afb..bfbade7c 100644 --- a/docs/guides/getting-started.md +++ b/docs/guides/getting-started.md @@ -189,7 +189,7 @@ AppRegistry.registerComponent('App', () => AppContainer) // prerender the app const { element, stylesheets } = AppRegistry.getApplication('App', { initialProps }); const initialHTML = ReactDOMServer.renderToString(element); -const initialStyles = stylesheets.map((sheet) => ReactDOMServer.renderToString(sheet)).join('\n'); +const initialStyles = stylesheets.map((sheet) => ReactDOMServer.renderToStaticMarkup(sheet)).join('\n'); // construct HTML document const document = ` diff --git a/src/apis/AppRegistry/__tests__/__snapshots__/renderApplication-test.js.snap b/src/apis/AppRegistry/__tests__/__snapshots__/renderApplication-test.js.snap index f1ebf9f2..e9e68268 100644 --- a/src/apis/AppRegistry/__tests__/__snapshots__/renderApplication-test.js.snap +++ b/src/apis/AppRegistry/__tests__/__snapshots__/renderApplication-test.js.snap @@ -9,69 +9,62 @@ exports[`apis/AppRegistry/renderApplication getApplication 1`] = ` `; exports[`apis/AppRegistry/renderApplication getApplication 2`] = ` -Array [ - , - , -] +"" +`; + +exports[`apis/AppRegistry/renderApplication getApplication 3`] = ` +"" `; diff --git a/src/apis/AppRegistry/__tests__/renderApplication-test.js b/src/apis/AppRegistry/__tests__/renderApplication-test.js index 06c4bc92..80d7c02f 100644 --- a/src/apis/AppRegistry/__tests__/renderApplication-test.js +++ b/src/apis/AppRegistry/__tests__/renderApplication-test.js @@ -2,6 +2,7 @@ import { getApplication } from '../renderApplication'; import React from 'react'; +import ReactDOMServer from 'react-dom/server'; const RootComponent = () =>
; @@ -10,6 +11,9 @@ describe('apis/AppRegistry/renderApplication', () => { const { element, stylesheets } = getApplication(RootComponent, {}); expect(element).toMatchSnapshot(); - expect(stylesheets).toMatchSnapshot(); + stylesheets.forEach(sheet => { + const result = ReactDOMServer.renderToStaticMarkup(sheet); + expect(result).toMatchSnapshot(); + }); }); }); diff --git a/src/apis/AppRegistry/renderApplication.js b/src/apis/AppRegistry/renderApplication.js index f4227dc7..7bf114ec 100644 --- a/src/apis/AppRegistry/renderApplication.js +++ b/src/apis/AppRegistry/renderApplication.js @@ -37,7 +37,8 @@ export function getApplication(RootComponent: ReactClass, initialProps: ); const stylesheets = StyleSheet.getStyleSheets().map(sheet => - + // ensure that CSS text is not escaped +