@@ -728,22 +728,41 @@ function validateFunctionComponentInDev(Component: any): void {
728728 }
729729}
730730
731+ function resolveDefaultProps ( Component : any , baseProps : Object ) : Object {
732+ if ( Component && Component . defaultProps ) {
733+ // Resolve default props. Taken from ReactElement
734+ const props = Object . assign ( { } , baseProps ) ;
735+ const defaultProps = Component . defaultProps ;
736+ for ( const propName in defaultProps ) {
737+ if ( props [ propName ] === undefined ) {
738+ props [ propName ] = defaultProps [ propName ] ;
739+ }
740+ }
741+ return props ;
742+ }
743+ return baseProps ;
744+ }
745+
731746function renderForwardRef (
732747 request : Request ,
733748 task : Task ,
734749 type : any ,
735750 props : Object ,
751+ ref : any ,
736752) : void {
737- throw new Error ( 'Not yet implemented element type.' ) ;
753+ renderWithHooks ( request , task , type , props , ref ) ;
738754}
739755
740756function renderMemo (
741757 request : Request ,
742758 task : Task ,
743759 type : any ,
744760 props : Object ,
761+ ref : any ,
745762) : void {
746- throw new Error ( 'Not yet implemented element type.' ) ;
763+ const innerType = type . type ;
764+ const resolvedProps = resolveDefaultProps ( innerType , props ) ;
765+ renderElement ( request , task , innerType , resolvedProps , ref ) ;
747766}
748767
749768function renderContextConsumer (
@@ -835,6 +854,7 @@ function renderElement(
835854 task : Task ,
836855 type : any ,
837856 props : Object ,
857+ ref : any ,
838858) : void {
839859 if ( typeof type === 'function' ) {
840860 if ( shouldConstruct ( type ) ) {
@@ -877,11 +897,11 @@ function renderElement(
877897 if ( typeof type === 'object' && type !== null ) {
878898 switch ( type . $$typeof ) {
879899 case REACT_FORWARD_REF_TYPE : {
880- renderForwardRef ( request , task , type , props ) ;
900+ renderForwardRef ( request , task , type , props , ref ) ;
881901 return ;
882902 }
883903 case REACT_MEMO_TYPE : {
884- renderMemo ( request , task , type , props ) ;
904+ renderMemo ( request , task , type , props , ref ) ;
885905 return ;
886906 }
887907 case REACT_PROVIDER_TYPE : {
@@ -961,7 +981,8 @@ function renderNodeDestructive(
961981 const element : React$Element < any > = ( node : any ) ;
962982 const type = element . type ;
963983 const props = element . props ;
964- renderElement ( request , task , type , props ) ;
984+ const ref = element . ref ;
985+ renderElement ( request , task , type , props , ref ) ;
965986 return ;
966987 }
967988 case REACT_PORTAL_TYPE :
0 commit comments