@@ -728,22 +728,41 @@ 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 ( request , task , innerType , resolvedProps , ref ) ;
747
766
}
748
767
749
768
function renderContextConsumer (
@@ -835,6 +854,7 @@ function renderElement(
835
854
task : Task ,
836
855
type : any ,
837
856
props : Object ,
857
+ ref : any ,
838
858
) : void {
839
859
if ( typeof type === 'function' ) {
840
860
if ( shouldConstruct ( type ) ) {
@@ -877,11 +897,11 @@ function renderElement(
877
897
if ( typeof type === 'object' && type !== null ) {
878
898
switch ( type . $$typeof ) {
879
899
case REACT_FORWARD_REF_TYPE : {
880
- renderForwardRef ( request , task , type , props ) ;
900
+ renderForwardRef ( request , task , type , props , ref ) ;
881
901
return ;
882
902
}
883
903
case REACT_MEMO_TYPE : {
884
- renderMemo ( request , task , type , props ) ;
904
+ renderMemo ( request , task , type , props , ref ) ;
885
905
return ;
886
906
}
887
907
case REACT_PROVIDER_TYPE : {
@@ -961,7 +981,8 @@ function renderNodeDestructive(
961
981
const element : React$Element < any > = ( node : any ) ;
962
982
const type = element . type ;
963
983
const props = element . props ;
964
- renderElement ( request , task , type , props ) ;
984
+ const ref = element . ref ;
985
+ renderElement ( request , task , type , props , ref ) ;
965
986
return ;
966
987
}
967
988
case REACT_PORTAL_TYPE :
0 commit comments