Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/renderers/art/ReactARTFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ const ARTRenderer = ReactFiberReconciler({

scheduleDeferredCallback: ReactDOMFrameScheduling.rIC,

shouldSetTextContent(props) {
shouldSetTextContent(type, props) {
return (
typeof props.children === 'string' || typeof props.children === 'number'
);
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/dom/fiber/ReactDOMFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ var DOMRenderer = ReactFiberReconciler({
updateProperties(domElement, updatePayload, type, oldProps, newProps);
},

shouldSetTextContent(props: Props): boolean {
shouldSetTextContent(type: string, props: Props): boolean {
return (
typeof props.children === 'string' ||
typeof props.children === 'number' ||
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/native/ReactNativeFiberRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ const NativeRenderer = ReactFiberReconciler({

scheduleDeferredCallback: global.requestIdleCallback,

shouldSetTextContent(props: Props): boolean {
shouldSetTextContent(type: string, props: Props): boolean {
// TODO (bvaughn) Revisit this decision.
// Always returning false simplifies the createInstance() implementation,
// But creates an additional child Fiber for raw text children.
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/noop/ReactNoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ var NoopRenderer = ReactFiberReconciler({
instance.prop = newProps.prop;
},

shouldSetTextContent(props: Props): boolean {
shouldSetTextContent(type: string, props: Props): boolean {
return (
typeof props.children === 'string' || typeof props.children === 'number'
);
Expand Down
7 changes: 4 additions & 3 deletions src/renderers/shared/fiber/ReactFiberBeginWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
}

let nextProps = workInProgress.pendingProps;
const type = workInProgress.type;
const prevProps = current !== null ? current.memoizedProps : null;
const memoizedProps = workInProgress.memoizedProps;
if (hasContextChanged()) {
Expand All @@ -422,7 +423,7 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
} else if (nextProps === null || memoizedProps === nextProps) {
if (
!useSyncScheduling &&
shouldDeprioritizeSubtree(workInProgress.type, memoizedProps) &&
shouldDeprioritizeSubtree(type, memoizedProps) &&
workInProgress.pendingWorkPriority !== OffscreenPriority
) {
// This subtree still has work, but it should be deprioritized so we need
Expand All @@ -445,15 +446,15 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
}

let nextChildren = nextProps.children;
const isDirectTextChild = shouldSetTextContent(nextProps);
const isDirectTextChild = shouldSetTextContent(type, nextProps);

if (isDirectTextChild) {
// We special case a direct text child of a host node. This is a common
// case. We won't handle it as a reified child. We will instead handle
// this in the host environment that also have access to this prop. That
// avoids allocating another HostText fiber and traversing it.
nextChildren = null;
} else if (prevProps && shouldSetTextContent(prevProps)) {
} else if (prevProps && shouldSetTextContent(type, prevProps)) {
// If we're switching from a direct text child to a normal child, or to
// empty, we need to schedule the text content to be reset.
workInProgress.effectTag |= ContentReset;
Expand Down
8 changes: 5 additions & 3 deletions src/renderers/shared/fiber/ReactFiberHydrationContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,18 @@ module.exports = function<T, P, I, TI, PI, C, CX, PL>(
return false;
}

const type = fiber.type;

// If we have any remaining hydratable nodes, we need to delete them now.
// We only do this deeper than head and body since they tend to have random
// other nodes in them. We also ignore components with pure text content in
// side of them.
// TODO: Better heuristic.
if (
fiber.tag !== HostComponent ||
(fiber.type !== 'head' &&
fiber.type !== 'body' &&
!shouldSetTextContent(fiber.memoizedProps))
(type !== 'head' &&
type !== 'body' &&
!shouldSetTextContent(type, fiber.memoizedProps))
) {
let nextInstance = nextHydratableInstance;
while (nextInstance) {
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/shared/fiber/ReactFiberReconciler.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export type HostConfig<T, P, I, TI, PI, C, CX, PL> = {
internalInstanceHandle: OpaqueHandle,
): void,

shouldSetTextContent(props: P): boolean,
shouldSetTextContent(type: T, props: P): boolean,
resetTextContent(instance: I): void,
shouldDeprioritizeSubtree(type: T, props: P): boolean,

Expand Down
2 changes: 1 addition & 1 deletion src/renderers/testing/ReactTestRendererFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ var TestRenderer = ReactFiberReconciler({
// noop
},

shouldSetTextContent(props: Props): boolean {
shouldSetTextContent(type: string, props: Props): boolean {
return false;
},

Expand Down