@@ -728,22 +728,47 @@ function validateFunctionComponentInDev(Component: any): void {
728
728
}
729
729
}
730
730
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
+
731
746
function renderForwardRef (
732
747
request : Request ,
733
748
task : Task ,
734
749
type : any ,
735
750
props : Object ,
751
+ ref : any ,
736
752
) : void {
737
- throw new Error ( 'Not yet implemented element type.' ) ;
753
+ renderWithHooks ( request , task , type , props , ref ) ;
738
754
}
739
755
740
756
function renderMemo (
741
757
request : Request ,
742
758
task : Task ,
743
759
type : any ,
744
760
props : Object ,
761
+ ref : any ,
745
762
) : void {
746
- throw new Error ( 'Not yet implemented element type.' ) ;
763
+ const innerType = type . type ;
764
+ const resolvedProps = resolveDefaultProps ( innerType , props ) ;
765
+ renderElement (
766
+ request ,
767
+ task ,
768
+ innerType ,
769
+ resolvedProps ,
770
+ ref ,
771
+ ) ;
747
772
}
748
773
749
774
function renderContextConsumer (
@@ -835,6 +860,7 @@ function renderElement(
835
860
task : Task ,
836
861
type : any ,
837
862
props : Object ,
863
+ ref : any ,
838
864
) : void {
839
865
if ( typeof type === 'function' ) {
840
866
if ( shouldConstruct ( type ) ) {
@@ -877,11 +903,11 @@ function renderElement(
877
903
if ( typeof type === 'object' && type !== null ) {
878
904
switch ( type . $$typeof ) {
879
905
case REACT_FORWARD_REF_TYPE : {
880
- renderForwardRef ( request , task , type , props ) ;
906
+ renderForwardRef ( request , task , type , props , ref ) ;
881
907
return ;
882
908
}
883
909
case REACT_MEMO_TYPE : {
884
- renderMemo ( request , task , type , props ) ;
910
+ renderMemo ( request , task , type , props , ref ) ;
885
911
return ;
886
912
}
887
913
case REACT_PROVIDER_TYPE : {
@@ -961,7 +987,8 @@ function renderNodeDestructive(
961
987
const element : React$Element < any > = ( node : any ) ;
962
988
const type = element . type ;
963
989
const props = element . props ;
964
- renderElement ( request , task , type , props ) ;
990
+ const ref = element . ref ;
991
+ renderElement ( request , task , type , props , ref ) ;
965
992
return ;
966
993
}
967
994
case REACT_PORTAL_TYPE :
0 commit comments