diff --git a/src/server.ts b/src/server.ts index aaa7cfe123..7532a7aba0 100644 --- a/src/server.ts +++ b/src/server.ts @@ -48,6 +48,8 @@ export function walkTree( // https://github.com/facebook/react/blob/master/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js#L66 if (Component.prototype && Component.prototype.isReactComponent) { const instance = new Component(props, context); + instance.props = props; + instance.context = context; // Override setState to just change the state, not queue up an update. // (we can't do the default React thing as we aren't mounted "properly" @@ -73,12 +75,12 @@ export function walkTree( child = Component(props, context); } - walkTree(child, childContext, visitor); + if (child) walkTree(child, childContext, visitor); } else { // a basic string or dom element, just get children if (element.props && element.props.children) { Children.forEach(element.props.children, (child: any) => { - walkTree(child, context, visitor); + if (child) walkTree(child, context, visitor); }); } }