diff --git a/lib/react_on_rails/server_rendering_js_code.rb b/lib/react_on_rails/server_rendering_js_code.rb index dc807b7a28..efd3494cec 100644 --- a/lib/react_on_rails/server_rendering_js_code.rb +++ b/lib/react_on_rails/server_rendering_js_code.rb @@ -40,6 +40,7 @@ def render(props_string, rails_context, redux_stores, react_component_name, rend var railsContext = #{rails_context}; #{redux_stores} var props = #{props_string}; + console.history = []; return ReactOnRails.serverRenderReactComponent({ name: '#{react_component_name}', domNodeId: '#{render_options.dom_id}', diff --git a/node_package/src/serverRenderReactComponent.ts b/node_package/src/serverRenderReactComponent.ts index 9974edc75a..6749f64c40 100644 --- a/node_package/src/serverRenderReactComponent.ts +++ b/node_package/src/serverRenderReactComponent.ts @@ -138,7 +138,7 @@ function createFinalResult( return JSON.stringify(createResultObject(result, consoleReplayScript, renderState)); } -function serverRenderReactComponentInternal(options: RenderParams): null | string | Promise { +function serverRenderReactComponent(options: RenderParams): null | string | Promise { const { name: componentName, domNodeId, trace, props, railsContext, renderingReturnsPromises, throwJsErrors } = options; let renderState: RenderState = { @@ -180,20 +180,4 @@ function serverRenderReactComponentInternal(options: RenderParams): null | strin return createFinalResult(renderState, componentName, throwJsErrors); } -const serverRenderReactComponent: typeof serverRenderReactComponentInternal = (options) => { - let result: string | Promise | null = null; - try { - result = serverRenderReactComponentInternal(options); - } finally { - // Reset console history after each render. - // See `RubyEmbeddedJavaScript.console_polyfill` for initialization. - // We don't need to clear the console history if the result is a promise - // Promises only supported in node renderer and node renderer takes care of cleanining console history - if (typeof result === 'string') { - console.history = []; - } - } - return result; -}; - export default serverRenderReactComponent;