Skip to content

Commit

Permalink
Flow
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Silbermann committed Feb 17, 2024
1 parent 8edecc0 commit 7c0f9a2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/react-dom-bindings/src/client/ReactDOMComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ function normalizeMarkupForTextOrAttribute(markup: mixed): string {

export function checkForUnmatchedText(
serverText: string,
clientText: string | number,
clientText: string | number | bigint,
isConcurrentMode: boolean,
shouldWarnDev: boolean,
) {
Expand Down Expand Up @@ -399,10 +399,12 @@ function setProp(
}
} else if (typeof value === 'number' || typeof value === 'bigint') {
if (__DEV__) {
// $FlowFixMe[unsafe-addition] Flow doesn't want us to use `+` operator with string and bigint
validateTextNesting('' + value, tag);
}
const canSetTextContent = tag !== 'body';
if (canSetTextContent) {
// $FlowFixMe[unsafe-addition] Flow doesn't want us to use `+` operator with string and bigint
setTextContent(domElement, '' + value);
}
}
Expand Down Expand Up @@ -954,6 +956,7 @@ function setPropOnCustomElement(
if (typeof value === 'string') {
setTextContent(domElement, value);
} else if (typeof value === 'number' || typeof value === 'bigint') {
// $FlowFixMe[unsafe-addition] Flow doesn't want us to use `+` operator with string and bigint
setTextContent(domElement, '' + value);
}
break;
Expand Down Expand Up @@ -2817,6 +2820,7 @@ export function diffHydratedProperties(
typeof children === 'number' ||
typeof children === 'bigint'
) {
// $FlowFixMe[unsafe-addition] Flow doesn't want us to use `+` operator with string and bigint
if (domElement.textContent !== '' + children) {
if (props.suppressHydrationWarning !== true) {
checkForUnmatchedText(
Expand Down
4 changes: 4 additions & 0 deletions packages/react-reconciler/src/ReactChildFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ function createChildReconciler(
// we can continue to replace it without aborting even if it is not a text
// node.
const created = createFiberFromText(
// $FlowFixMe[unsafe-addition] Flow doesn't want us to use `+` operator with string and bigint
'' + newChild,
returnFiber.mode,
lanes,
Expand Down Expand Up @@ -688,6 +689,7 @@ function createChildReconciler(
return updateTextNode(
returnFiber,
oldFiber,
// $FlowFixMe[unsafe-addition] Flow doesn't want us to use `+` operator with string and bigint
'' + newChild,
lanes,
debugInfo,
Expand Down Expand Up @@ -806,6 +808,7 @@ function createChildReconciler(
return updateTextNode(
returnFiber,
matchedFiber,
// $FlowFixMe[unsafe-addition] Flow doesn't want us to use `+` operator with string and bigint
'' + newChild,
lanes,
debugInfo,
Expand Down Expand Up @@ -1617,6 +1620,7 @@ function createChildReconciler(
reconcileSingleTextNode(
returnFiber,
currentFirstChild,
// $FlowFixMe[unsafe-addition] Flow doesn't want us to use `+` operator with string and bigint
'' + newChild,
lanes,
),
Expand Down

0 comments on commit 7c0f9a2

Please sign in to comment.