@@ -45,6 +45,7 @@ import type {DOMContainer} from './ReactDOM';
4545import type {
4646 ReactDOMEventResponder ,
4747 ReactDOMEventComponentInstance ,
48+ ReactDOMFundamentalComponentInstance ,
4849} from 'shared/ReactDOMTypes' ;
4950import {
5051 addRootEventTypesForComponentInstance ,
@@ -103,6 +104,7 @@ export type NoTimeout = -1;
103104import {
104105 enableSuspenseServerRenderer ,
105106 enableFlareAPI ,
107+ enableFundamentalAPI ,
106108} from 'shared/ReactFeatureFlags' ;
107109import warning from 'shared/warning' ;
108110
@@ -882,3 +884,65 @@ export function unmountEventComponent(
882884 unmountEventResponder ( eventComponentInstance ) ;
883885 }
884886}
887+
888+ export function getFundamentalComponentInstance (
889+ fundamentalInstance : ReactDOMFundamentalComponentInstance ,
890+ ) : Instance {
891+ if ( enableFundamentalAPI ) {
892+ const { currentFiber, impl, props, state} = fundamentalInstance ;
893+ const instance = impl . getInstance ( null , props , state ) ;
894+ precacheFiberNode ( currentFiber , instance ) ;
895+ return instance ;
896+ }
897+ // Because of the flag above, this gets around the Flow error;
898+ return ( null : any ) ;
899+ }
900+
901+ export function mountFundamentalComponent (
902+ fundamentalInstance : ReactDOMFundamentalComponentInstance ,
903+ ) : void {
904+ if ( enableFundamentalAPI ) {
905+ const { impl, instance, props, state} = fundamentalInstance ;
906+ const onMount = impl . onMount ;
907+ if ( onMount !== undefined ) {
908+ onMount ( null , instance , props , state ) ;
909+ }
910+ }
911+ }
912+
913+ export function shouldUpdateFundamentalComponent (
914+ fundamentalInstance : ReactDOMFundamentalComponentInstance ,
915+ ) : boolean {
916+ if ( enableFundamentalAPI ) {
917+ const { impl, prevProps, props, state} = fundamentalInstance ;
918+ const shouldUpdate = impl . shouldUpdate ;
919+ if ( shouldUpdate !== undefined ) {
920+ return shouldUpdate ( null , prevProps , props , state ) ;
921+ }
922+ }
923+ return true ;
924+ }
925+
926+ export function updateFundamentalComponent (
927+ fundamentalInstance : ReactDOMFundamentalComponentInstance ,
928+ ) : void {
929+ if ( enableFundamentalAPI ) {
930+ const { impl, instance, prevProps, props, state} = fundamentalInstance ;
931+ const onUpdate = impl . onUpdate ;
932+ if ( onUpdate !== undefined ) {
933+ onUpdate ( null , instance , prevProps , props , state ) ;
934+ }
935+ }
936+ }
937+
938+ export function unmountFundamentalComponent (
939+ fundamentalInstance : ReactDOMFundamentalComponentInstance ,
940+ ) : void {
941+ if ( enableFundamentalAPI ) {
942+ const { impl, instance, props, state} = fundamentalInstance ;
943+ const onUnmount = impl . onUnmount ;
944+ if ( onUnmount !== undefined ) {
945+ onUnmount ( null , instance , props , state ) ;
946+ }
947+ }
948+ }
0 commit comments