MCPcopy
hub / github.com/facebook/react / markRef

Function markRef

packages/react-reconciler/src/ReactFiberBeginWork.js:1382–1401  ·  view source on GitHub ↗
(current: Fiber | null, workInProgress: Fiber)

Source from the content-addressed store, hash-verified

1380}
1381
1382function markRef(current: Fiber | null, workInProgress: Fiber) {
1383 // TODO: Check props.ref instead of fiber.ref when enableRefAsProp is on.
1384 const ref = workInProgress.ref;
1385 if (ref === null) {
1386 if (current !== null && current.ref !== null) {
1387 // Schedule a Ref effect
1388 workInProgress.flags |= Ref | RefStatic;
1389 }
1390 } else {
1391 if (typeof ref !== 'function' && typeof ref !== 'object') {
1392 throw new Error(
1393 'Expected ref to be a function, an object returned by React.createRef(), or undefined/null.',
1394 );
1395 }
1396 if (current === null || current.ref !== ref) {
1397 // Schedule a Ref effect
1398 workInProgress.flags |= Ref | RefStatic;
1399 }
1400 }
1401}
1402
1403function mountIncompleteFunctionComponent(
1404 _current: null | Fiber,

Callers 7

updateFragmentFunction · 0.85
finishClassComponentFunction · 0.85
updateHostComponentFunction · 0.85
updateHostHoistableFunction · 0.85
updateHostSingletonFunction · 0.85
updateViewTransitionFunction · 0.85
updateScopeComponentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected