@@ -62,6 +62,7 @@ import {
62
62
current as ReactCurrentFiberCurrent ,
63
63
} from './ReactCurrentFiber' ;
64
64
import { StrictMode } from './ReactTypeOfMode' ;
65
+ import { Sync } from './ReactFiberExpirationTime' ;
65
66
66
67
type OpaqueRoot = FiberRoot ;
67
68
@@ -339,10 +340,49 @@ export function findHostInstanceWithNoPortals(
339
340
return hostFiber . stateNode ;
340
341
}
341
342
343
+ let overrideProps = null ;
344
+
345
+ if ( __DEV__ ) {
346
+ const copyWithSetImpl = (
347
+ obj : Object | Array < any > ,
348
+ path : Array < string | number > ,
349
+ idx : number ,
350
+ value : any ,
351
+ ) => {
352
+ if ( idx >= path . length ) {
353
+ return value ;
354
+ }
355
+ const key = path [ idx ] ;
356
+ const updated = Array . isArray ( obj ) ? obj . slice ( ) : { ...obj } ;
357
+ // $FlowFixMe number or string is fine here
358
+ updated [ key ] = copyWithSetImpl ( obj [ key ] , path , idx + 1 , value ) ;
359
+ return updated ;
360
+ } ;
361
+
362
+ const copyWithSet = (
363
+ obj : Object | Array < any > ,
364
+ path : Array < string | number > ,
365
+ value : any ,
366
+ ) : Object | Array < any > => {
367
+ return copyWithSetImpl ( obj , path , 0 , value ) ;
368
+ } ;
369
+
370
+ // Support DevTools props for function components, forwardRef, memo, host components, etc.
371
+ overrideProps = ( fiber : Fiber , path : Array < string | number > , value : any ) => {
372
+ flushPassiveEffects ( ) ;
373
+ fiber . pendingProps = copyWithSet ( fiber . memoizedProps , path , value ) ;
374
+ if ( fiber . alternate ) {
375
+ fiber . alternate . pendingProps = fiber . pendingProps ;
376
+ }
377
+ scheduleWork ( fiber , Sync ) ;
378
+ } ;
379
+ }
380
+
342
381
export function injectIntoDevTools ( devToolsConfig : DevToolsConfig ) : boolean {
343
382
const { findFiberByHostInstance} = devToolsConfig ;
344
383
return injectInternals ( {
345
384
...devToolsConfig ,
385
+ overrideProps,
346
386
findHostInstanceByFiber ( fiber : Fiber ) : Instance | TextInstance | null {
347
387
const hostFiber = findCurrentHostFiber ( fiber ) ;
348
388
if ( hostFiber === null ) {
0 commit comments