Skip to content

Commit 65bbda7

Browse files
authored
Rename Chunks API to Blocks (facebook#18086)
Sounds like this is the name we're going with. This also helps us distinguish it from other "chunking" implementation details.
1 parent 8b596e0 commit 65bbda7

24 files changed

+88
-88
lines changed

packages/react-debug-tools/src/ReactDebugHooks.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
SimpleMemoComponent,
2626
ContextProvider,
2727
ForwardRef,
28-
Chunk,
28+
Block,
2929
} from 'shared/ReactWorkTags';
3030

3131
type CurrentDispatcherRef = typeof ReactSharedInternals.ReactCurrentDispatcher;
@@ -628,7 +628,7 @@ export function inspectHooksOfFiber(
628628
fiber.tag !== FunctionComponent &&
629629
fiber.tag !== SimpleMemoComponent &&
630630
fiber.tag !== ForwardRef &&
631-
fiber.tag !== Chunk
631+
fiber.tag !== Block
632632
) {
633633
throw new Error(
634634
'Unknown Fiber. Needs to be a function component to inspect hooks.',

packages/react-reconciler/src/ReactChildFiber.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ import {
1919
REACT_ELEMENT_TYPE,
2020
REACT_FRAGMENT_TYPE,
2121
REACT_PORTAL_TYPE,
22-
REACT_CHUNK_TYPE,
22+
REACT_BLOCK_TYPE,
2323
} from 'shared/ReactSymbols';
2424
import {
2525
FunctionComponent,
2626
ClassComponent,
2727
HostText,
2828
HostPortal,
2929
Fragment,
30-
Chunk,
30+
Block,
3131
} from 'shared/ReactWorkTags';
3232
import invariant from 'shared/invariant';
33-
import {warnAboutStringRefs, enableChunksAPI} from 'shared/ReactFeatureFlags';
33+
import {warnAboutStringRefs, enableBlocksAPI} from 'shared/ReactFeatureFlags';
3434

3535
import {
3636
createWorkInProgress,
@@ -416,9 +416,9 @@ function ChildReconciler(shouldTrackSideEffects) {
416416
}
417417
return existing;
418418
} else if (
419-
enableChunksAPI &&
420-
current.tag === Chunk &&
421-
element.type.$$typeof === REACT_CHUNK_TYPE &&
419+
enableBlocksAPI &&
420+
current.tag === Block &&
421+
element.type.$$typeof === REACT_BLOCK_TYPE &&
422422
element.type.render === current.type.render
423423
) {
424424
// Same as above but also update the .type field.
@@ -1175,10 +1175,10 @@ function ChildReconciler(shouldTrackSideEffects) {
11751175
}
11761176
break;
11771177
}
1178-
case Chunk:
1179-
if (enableChunksAPI) {
1178+
case Block:
1179+
if (enableBlocksAPI) {
11801180
if (
1181-
element.type.$$typeof === REACT_CHUNK_TYPE &&
1181+
element.type.$$typeof === REACT_BLOCK_TYPE &&
11821182
element.type.render === child.type.render
11831183
) {
11841184
deleteRemainingChildren(returnFiber, child.sibling);
@@ -1192,7 +1192,7 @@ function ChildReconciler(shouldTrackSideEffects) {
11921192
return existing;
11931193
}
11941194
}
1195-
// We intentionally fallthrough here if enableChunksAPI is not on.
1195+
// We intentionally fallthrough here if enableBlocksAPI is not on.
11961196
// eslint-disable-next-lined no-fallthrough
11971197
default: {
11981198
if (

packages/react-reconciler/src/ReactFiber.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import {
3333
enableFundamentalAPI,
3434
enableUserTimingAPI,
3535
enableScopeAPI,
36-
enableChunksAPI,
36+
enableBlocksAPI,
3737
} from 'shared/ReactFeatureFlags';
3838
import {NoEffect, Placement} from 'shared/ReactSideEffectTags';
3939
import {ConcurrentRoot, BlockingRoot} from 'shared/ReactRootTags';
@@ -59,7 +59,7 @@ import {
5959
LazyComponent,
6060
FundamentalComponent,
6161
ScopeComponent,
62-
Chunk,
62+
Block,
6363
} from 'shared/ReactWorkTags';
6464
import getComponentName from 'shared/getComponentName';
6565

@@ -91,7 +91,7 @@ import {
9191
REACT_LAZY_TYPE,
9292
REACT_FUNDAMENTAL_TYPE,
9393
REACT_SCOPE_TYPE,
94-
REACT_CHUNK_TYPE,
94+
REACT_BLOCK_TYPE,
9595
} from 'shared/ReactSymbols';
9696

9797
let hasBadMapPolyfill;
@@ -391,9 +391,9 @@ export function resolveLazyComponentTag(Component: Function): WorkTag {
391391
if ($$typeof === REACT_MEMO_TYPE) {
392392
return MemoComponent;
393393
}
394-
if (enableChunksAPI) {
395-
if ($$typeof === REACT_CHUNK_TYPE) {
396-
return Chunk;
394+
if (enableBlocksAPI) {
395+
if ($$typeof === REACT_BLOCK_TYPE) {
396+
return Block;
397397
}
398398
}
399399
}
@@ -676,8 +676,8 @@ export function createFiberFromTypeAndProps(
676676
fiberTag = LazyComponent;
677677
resolvedType = null;
678678
break getTag;
679-
case REACT_CHUNK_TYPE:
680-
fiberTag = Chunk;
679+
case REACT_BLOCK_TYPE:
680+
fiberTag = Block;
681681
break getTag;
682682
case REACT_FUNDAMENTAL_TYPE:
683683
if (enableFundamentalAPI) {

packages/react-reconciler/src/ReactFiberBeginWork.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import {
4242
IncompleteClassComponent,
4343
FundamentalComponent,
4444
ScopeComponent,
45-
Chunk,
45+
Block,
4646
} from 'shared/ReactWorkTags';
4747
import {
4848
NoEffect,
@@ -65,7 +65,7 @@ import {
6565
enableFundamentalAPI,
6666
warnAboutDefaultPropsOnFunctionComponents,
6767
enableScopeAPI,
68-
enableChunksAPI,
68+
enableBlocksAPI,
6969
} from 'shared/ReactFeatureFlags';
7070
import invariant from 'shared/invariant';
7171
import shallowEqual from 'shared/shallowEqual';
@@ -701,19 +701,19 @@ function updateFunctionComponent(
701701
return workInProgress.child;
702702
}
703703

704-
function updateChunk(
704+
function updateBlock(
705705
current: Fiber | null,
706706
workInProgress: Fiber,
707-
chunk: any,
707+
block: any,
708708
nextProps: any,
709709
renderExpirationTime: ExpirationTime,
710710
) {
711711
// TODO: current can be non-null here even if the component
712712
// hasn't yet mounted. This happens after the first render suspends.
713713
// We'll need to figure out if this is fine or can cause issues.
714714

715-
const render = chunk.render;
716-
const data = chunk.query();
715+
const render = block.render;
716+
const data = block.query();
717717

718718
// The rest is a fork of updateFunctionComponent
719719
let nextChildren;
@@ -1215,10 +1215,10 @@ function mountLazyComponent(
12151215
);
12161216
return child;
12171217
}
1218-
case Chunk: {
1219-
if (enableChunksAPI) {
1218+
case Block: {
1219+
if (enableBlocksAPI) {
12201220
// TODO: Resolve for Hot Reloading.
1221-
child = updateChunk(
1221+
child = updateBlock(
12221222
null,
12231223
workInProgress,
12241224
Component,
@@ -3289,14 +3289,14 @@ function beginWork(
32893289
}
32903290
break;
32913291
}
3292-
case Chunk: {
3293-
if (enableChunksAPI) {
3294-
const chunk = workInProgress.type;
3292+
case Block: {
3293+
if (enableBlocksAPI) {
3294+
const block = workInProgress.type;
32953295
const props = workInProgress.pendingProps;
3296-
return updateChunk(
3296+
return updateBlock(
32973297
current,
32983298
workInProgress,
3299-
chunk,
3299+
block,
33003300
props,
33013301
renderExpirationTime,
33023302
);

packages/react-reconciler/src/ReactFiberCommitWork.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import {
5353
SuspenseListComponent,
5454
FundamentalComponent,
5555
ScopeComponent,
56-
Chunk,
56+
Block,
5757
} from 'shared/ReactWorkTags';
5858
import {
5959
invokeGuardedCallback,
@@ -249,7 +249,7 @@ function commitBeforeMutationLifeCycles(
249249
case FunctionComponent:
250250
case ForwardRef:
251251
case SimpleMemoComponent:
252-
case Chunk: {
252+
case Block: {
253253
return;
254254
}
255255
case ClassComponent: {
@@ -426,7 +426,7 @@ export function commitPassiveHookEffects(finishedWork: Fiber): void {
426426
case FunctionComponent:
427427
case ForwardRef:
428428
case SimpleMemoComponent:
429-
case Chunk: {
429+
case Block: {
430430
// TODO (#17945) We should call all passive destroy functions (for all fibers)
431431
// before calling any create functions. The current approach only serializes
432432
// these for a single fiber.
@@ -450,7 +450,7 @@ function commitLifeCycles(
450450
case FunctionComponent:
451451
case ForwardRef:
452452
case SimpleMemoComponent:
453-
case Chunk: {
453+
case Block: {
454454
// At this point layout effects have already been destroyed (during mutation phase).
455455
// This is done to prevent sibling component effects from interfering with each other,
456456
// e.g. a destroy function in one component should never override a ref set
@@ -779,7 +779,7 @@ function commitUnmount(
779779
case ForwardRef:
780780
case MemoComponent:
781781
case SimpleMemoComponent:
782-
case Chunk: {
782+
case Block: {
783783
const updateQueue: FunctionComponentUpdateQueue | null = (current.updateQueue: any);
784784
if (updateQueue !== null) {
785785
const lastEffect = updateQueue.lastEffect;
@@ -1360,7 +1360,7 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void {
13601360
case ForwardRef:
13611361
case MemoComponent:
13621362
case SimpleMemoComponent:
1363-
case Chunk: {
1363+
case Block: {
13641364
// Layout effects are destroyed during the mutation phase so that all
13651365
// destroy functions for all fibers are called before any create functions.
13661366
// This prevents sibling component effects from interfering with each other,
@@ -1403,7 +1403,7 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void {
14031403
case ForwardRef:
14041404
case MemoComponent:
14051405
case SimpleMemoComponent:
1406-
case Chunk: {
1406+
case Block: {
14071407
// Layout effects are destroyed during the mutation phase so that all
14081408
// destroy functions for all fibers are called before any create functions.
14091409
// This prevents sibling component effects from interfering with each other,

packages/react-reconciler/src/ReactFiberCompleteWork.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import {
5151
IncompleteClassComponent,
5252
FundamentalComponent,
5353
ScopeComponent,
54-
Chunk,
54+
Block,
5555
} from 'shared/ReactWorkTags';
5656
import {NoMode, BlockingMode} from './ReactTypeOfMode';
5757
import {
@@ -119,7 +119,7 @@ import {
119119
enableDeprecatedFlareAPI,
120120
enableFundamentalAPI,
121121
enableScopeAPI,
122-
enableChunksAPI,
122+
enableBlocksAPI,
123123
} from 'shared/ReactFeatureFlags';
124124
import {
125125
markSpawnedWork,
@@ -1295,8 +1295,8 @@ function completeWork(
12951295
}
12961296
break;
12971297
}
1298-
case Chunk:
1299-
if (enableChunksAPI) {
1298+
case Block:
1299+
if (enableBlocksAPI) {
13001300
return null;
13011301
}
13021302
break;

packages/react-reconciler/src/ReactFiberWorkLoop.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ import {
8888
ForwardRef,
8989
MemoComponent,
9090
SimpleMemoComponent,
91-
Chunk,
91+
Block,
9292
} from 'shared/ReactWorkTags';
9393
import {
9494
NoEffect,
@@ -2682,7 +2682,7 @@ function warnAboutUpdateOnUnmountedFiberInDEV(fiber) {
26822682
tag !== ForwardRef &&
26832683
tag !== MemoComponent &&
26842684
tag !== SimpleMemoComponent &&
2685-
tag !== Chunk
2685+
tag !== Block
26862686
) {
26872687
// Only warn for user-defined components, not internal ones like Suspense.
26882688
return;

packages/react-reconciler/src/__tests__/ReactChunks-test.js renamed to packages/react-reconciler/src/__tests__/ReactBlocks-test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ let React;
1212
let ReactNoop;
1313
let useState;
1414
let Suspense;
15-
let chunk;
15+
let block;
1616
let readString;
1717

18-
describe('ReactChunks', () => {
18+
describe('ReactBlocks', () => {
1919
beforeEach(() => {
2020
jest.resetModules();
2121

2222
React = require('react');
2323
ReactNoop = require('react-noop-renderer');
2424

25-
chunk = React.chunk;
25+
block = React.block;
2626
useState = React.useState;
2727
Suspense = React.Suspense;
2828
let cache = new Map();
@@ -63,7 +63,7 @@ describe('ReactChunks', () => {
6363
);
6464
}
6565

66-
let loadUser = chunk(Query, Render);
66+
let loadUser = block(Query, Render);
6767

6868
function App({User}) {
6969
return (
@@ -102,7 +102,7 @@ describe('ReactChunks', () => {
102102
);
103103
}
104104

105-
let loadUser = chunk(Query, Render);
105+
let loadUser = block(Query, Render);
106106

107107
function App({User}) {
108108
return (
@@ -164,7 +164,7 @@ describe('ReactChunks', () => {
164164
);
165165
}
166166

167-
let loadUser = chunk(Query, Render);
167+
let loadUser = block(Query, Render);
168168

169169
function App({User}) {
170170
return (

packages/react-test-renderer/src/ReactTestRenderer.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import {
3737
Profiler,
3838
MemoComponent,
3939
SimpleMemoComponent,
40-
Chunk,
40+
Block,
4141
IncompleteClassComponent,
4242
ScopeComponent,
4343
} from 'shared/ReactWorkTags';
@@ -188,9 +188,9 @@ function toTree(node: ?Fiber) {
188188
instance: null,
189189
rendered: childrenToTree(node.child),
190190
};
191-
case Chunk:
191+
case Block:
192192
return {
193-
nodeType: 'chunk',
193+
nodeType: 'block',
194194
type: node.type,
195195
props: {...node.memoizedProps},
196196
instance: null,
@@ -233,7 +233,7 @@ const validWrapperTypes = new Set([
233233
ForwardRef,
234234
MemoComponent,
235235
SimpleMemoComponent,
236-
Chunk,
236+
Block,
237237
// Normally skipped, but used when there's more than one root child.
238238
HostRoot,
239239
]);

0 commit comments

Comments
 (0)