Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
[ghstack-poisoned]
  • Loading branch information
poteto committed Jul 12, 2024
2 parents 05a0efe + bac1e48 commit a52cbbc
Show file tree
Hide file tree
Showing 31 changed files with 157 additions and 64 deletions.
15 changes: 11 additions & 4 deletions .github/workflows/runtime_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ on:
branches: [main]
pull_request:
paths-ignore:
- 'compiler/**'
- compiler/**

env:
TZ: /usr/share/zoneinfo/America/Los_Angeles

jobs:
build_and_lint:
Expand All @@ -20,17 +23,21 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18.x
cache: "yarn"
node-version: 18.20.1
cache: yarn
cache-dependency-path: yarn.lock
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11.0.22
- name: Restore cached node_modules
uses: actions/cache@v4
id: node_modules
with:
path: "**/node_modules"
key: ${{ runner.arch }}-${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}
- run: yarn install --frozen-lockfile
- run: NODE_ENV=development yarn build --index=${{ matrix.worker_id }} --total=20 --r=${{ matrix.release_channel }} --ci=github
- run: yarn build --index=${{ matrix.worker_id }} --total=20 --r=${{ matrix.release_channel }} --ci=github
env:
CI: github
RELEASE_CHANNEL: ${{ matrix.release_channel }}
Expand Down
4 changes: 2 additions & 2 deletions packages/react-client/src/ReactClientConsoleConfigBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ export function printToConsole(
);
}

if (methodName === 'error') {
if (methodName === 'error' && __DEV__) {
error.apply(console, newArgs);
} else if (methodName === 'warn') {
} else if (methodName === 'warn' && __DEV__) {
warn.apply(console, newArgs);
} else {
// $FlowFixMe[invalid-computed-prop]
Expand Down
4 changes: 2 additions & 2 deletions packages/react-client/src/ReactClientConsoleConfigPlain.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ export function printToConsole(
newArgs.splice(offset, 0, badgeFormat, pad + badgeName + pad);
}

if (methodName === 'error') {
if (methodName === 'error' && __DEV__) {
error.apply(console, newArgs);
} else if (methodName === 'warn') {
} else if (methodName === 'warn' && __DEV__) {
warn.apply(console, newArgs);
} else {
// $FlowFixMe[invalid-computed-prop]
Expand Down
4 changes: 2 additions & 2 deletions packages/react-client/src/ReactClientConsoleConfigServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ export function printToConsole(
);
}

if (methodName === 'error') {
if (methodName === 'error' && __DEV__) {
error.apply(console, newArgs);
} else if (methodName === 'warn') {
} else if (methodName === 'warn' && __DEV__) {
warn.apply(console, newArgs);
} else {
// $FlowFixMe[invalid-computed-prop]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ describe('ReactDOMServerIntegration', () => {
});

itRenders('stateless child with context', async render => {
if (gate(flags => flags.disableLegacyContextForFunctionComponents)) {
return;
}
function FunctionChildWithContext(props, context) {
return <div>{context.text}</div>;
}
Expand Down Expand Up @@ -118,6 +121,9 @@ describe('ReactDOMServerIntegration', () => {
});

itRenders('stateless child without context', async render => {
if (gate(flags => flags.disableLegacyContextForFunctionComponents)) {
return;
}
function FunctionChildWithoutContext(props, context) {
// this should render blank; context isn't passed to this component.
return <div>{context.text}</div>;
Expand Down Expand Up @@ -151,6 +157,9 @@ describe('ReactDOMServerIntegration', () => {
});

itRenders('stateless child with wrong context', async render => {
if (gate(flags => flags.disableLegacyContextForFunctionComponents)) {
return;
}
function FunctionChildWithWrongContext(props, context) {
// this should render blank; context.text isn't passed to this component.
return <div id="statelessWrongChild">{context.text}</div>;
Expand All @@ -169,6 +178,9 @@ describe('ReactDOMServerIntegration', () => {
});

itRenders('with context passed through to a grandchild', async render => {
if (gate(flags => flags.disableLegacyContextForFunctionComponents)) {
return;
}
function Grandchild(props, context) {
return <div>{context.text}</div>;
}
Expand All @@ -186,6 +198,9 @@ describe('ReactDOMServerIntegration', () => {
});

itRenders('a child context overriding a parent context', async render => {
if (gate(flags => flags.disableLegacyContextForFunctionComponents)) {
return;
}
const Grandchild = (props, context) => {
return <div>{context.text}</div>;
};
Expand All @@ -203,6 +218,9 @@ describe('ReactDOMServerIntegration', () => {
});

itRenders('a child context merged with a parent context', async render => {
if (gate(flags => flags.disableLegacyContextForFunctionComponents)) {
return;
}
class Parent extends React.Component {
getChildContext() {
return {text1: 'purple'};
Expand Down Expand Up @@ -244,6 +262,9 @@ describe('ReactDOMServerIntegration', () => {
itRenders(
'with a call to componentWillMount before getChildContext',
async render => {
if (gate(flags => flags.disableLegacyContextForFunctionComponents)) {
return;
}
class WillMountContext extends React.Component {
getChildContext() {
return {text: this.state.text};
Expand All @@ -270,6 +291,9 @@ describe('ReactDOMServerIntegration', () => {
itRenders(
'if getChildContext exists but childContextTypes is missing with a warning',
async render => {
if (gate(flags => flags.disableLegacyContextForFunctionComponents)) {
return;
}
function HopefulChild(props, context) {
return context.foo || 'nope';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ describe('ReactFunctionComponent', () => {
]);
});

// @gate !disableLegacyContext
// @gate !disableLegacyContext && !disableLegacyContextForFunctionComponents
it('should receive context', async () => {
class Parent extends React.Component {
static childContextTypes = {
Expand Down
2 changes: 2 additions & 0 deletions packages/react-native-renderer/src/ReactNativeTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,15 @@ export type ViewConfig = $ReadOnly<{
}>,
...
}>,
supportsRawText?: boolean,
uiViewClassName: string,
validAttributes: AttributeConfiguration,
}>;

export type PartialViewConfig = $ReadOnly<{
bubblingEventTypes?: $PropertyType<ViewConfig, 'bubblingEventTypes'>,
directEventTypes?: $PropertyType<ViewConfig, 'directEventTypes'>,
supportsRawText?: boolean,
uiViewClassName: string,
validAttributes?: PartialAttributeConfiguration,
}>;
Expand Down
4 changes: 2 additions & 2 deletions packages/react-reconciler/src/ReactCurrentFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function getCurrentFiberOwnerNameInDevOrNull(): string | null {
return null;
}

function getCurrentFiberStackInDev(stack: null | Error): string {
function getCurrentFiberStackInDev(): string {
if (__DEV__) {
if (current === null) {
return '';
Expand All @@ -43,7 +43,7 @@ function getCurrentFiberStackInDev(stack: null | Error): string {
// TODO: The above comment is not actually true. We might be
// in a commit phase or preemptive set state callback.
if (enableOwnerStacks) {
return getOwnerStackByFiberInDev(current, stack);
return getOwnerStackByFiberInDev(current);
}
return getStackByFiberInDevAndProd(current);
}
Expand Down
3 changes: 2 additions & 1 deletion packages/react-reconciler/src/ReactFiberBeginWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ import {
import {
debugRenderPhaseSideEffectsForStrictMode,
disableLegacyContext,
disableLegacyContextForFunctionComponents,
enableProfilerCommitHooks,
enableProfilerTimer,
enableScopeAPI,
Expand Down Expand Up @@ -1158,7 +1159,7 @@ function updateFunctionComponent(
}

let context;
if (!disableLegacyContext) {
if (!disableLegacyContext && !disableLegacyContextForFunctionComponents) {
const unmaskedContext = getUnmaskedContext(workInProgress, Component, true);
context = getMaskedContext(workInProgress, unmaskedContext);
}
Expand Down
16 changes: 1 addition & 15 deletions packages/react-reconciler/src/ReactFiberComponentStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,27 +91,13 @@ function describeFunctionComponentFrameWithoutLineNumber(fn: Function): string {
return name ? describeBuiltInComponentFrame(name) : '';
}

export function getOwnerStackByFiberInDev(
workInProgress: Fiber,
topStack: null | Error,
): string {
export function getOwnerStackByFiberInDev(workInProgress: Fiber): string {
if (!enableOwnerStacks || !__DEV__) {
return '';
}
try {
let info = '';

if (topStack) {
// Prefix with a filtered version of the currently executing
// stack. This information will be available in the native
// stack regardless but it's hidden since we're reprinting
// the stack on top of it.
const formattedTopStack = formatOwnerStack(topStack);
if (formattedTopStack !== '') {
info += '\n' + formattedTopStack;
}
}

if (workInProgress.tag === HostText) {
// Text nodes never have an owner/stack because they're not created through JSX.
// We use the parent since text nodes are always created through a host parent.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1701,7 +1701,7 @@ describe('ReactIncremental', () => {
expect(instance.state.n).toEqual(3);
});

// @gate !disableLegacyContext
// @gate !disableLegacyContext && !disableLegacyContextForFunctionComponents
it('merges and masks context', async () => {
class Intl extends React.Component {
static childContextTypes = {
Expand Down Expand Up @@ -1954,7 +1954,7 @@ describe('ReactIncremental', () => {
]);
});

// @gate !disableLegacyContext
// @gate !disableLegacyContext && !disableLegacyContextForFunctionComponents
it('reads context when setState is below the provider', async () => {
let statefulInst;

Expand Down Expand Up @@ -2046,7 +2046,7 @@ describe('ReactIncremental', () => {
assertLog([]);
});

// @gate !disableLegacyContext
// @gate !disableLegacyContext && !disableLegacyContextForFunctionComponents
it('reads context when setState is above the provider', async () => {
let statefulInst;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,7 @@ describe('ReactIncrementalErrorHandling', () => {
// because it's used for new context, suspense, and many other features.
// It has to be tested independently for each feature anyway. So although it
// doesn't look like it, this test is specific to legacy context.
// @gate !disableLegacyContext
// @gate !disableLegacyContext && !disableLegacyContextForFunctionComponents
it('unwinds the context stack correctly on error', async () => {
class Provider extends React.Component {
static childContextTypes = {message: PropTypes.string};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,18 @@ describe('ReactLazy', () => {
unstable_isConcurrent: true,
});

function App() {
return (
<Suspense fallback={<Text text="Loading..." />}>
<LazyText text="Hi" />
</Suspense>
);
}

let error;
try {
await act(() => {
root.update(
<Suspense fallback={<Text text="Loading..." />}>
<LazyText text="Hi" />
</Suspense>,
);
root.update(<App />);
});
} catch (e) {
error = e;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/__tests__/ReactUse-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1562,7 +1562,7 @@ describe('ReactUse', () => {
expect(root).toMatchRenderedOutput('Async!');
});

// @gate !disableLegacyContext
// @gate !disableLegacyContext && !disableLegacyContextForFunctionComponents
it('unwrap uncached promises in component that accesses legacy context', async () => {
class ContextProvider extends React.Component {
static childContextTypes = {
Expand Down
3 changes: 2 additions & 1 deletion packages/react-server/src/ReactFizzServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ import {
import ReactSharedInternals from 'shared/ReactSharedInternals';
import {
disableLegacyContext,
disableLegacyContextForFunctionComponents,
enableScopeAPI,
enableSuspenseAvoidThisFallbackFizz,
enableCache,
Expand Down Expand Up @@ -1654,7 +1655,7 @@ function renderFunctionComponent(
props: any,
): void {
let legacyContext;
if (!disableLegacyContext) {
if (!disableLegacyContext && !disableLegacyContextForFunctionComponents) {
legacyContext = getMaskedContext(Component, task.legacyContext);
}
if (__DEV__) {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/ReactOwnerStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ export function captureOwnerStack(): null | string {
}
// The current stack will be the owner stack if enableOwnerStacks is true
// which it is always here. Otherwise it's the parent stack.
return getCurrentStack(null);
return getCurrentStack();
}
60 changes: 60 additions & 0 deletions packages/react/src/ReactServer.fb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

export {default as __SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE} from './ReactSharedInternalsServer';

import {forEach, map, count, toArray, only} from './ReactChildren';
import {
REACT_FRAGMENT_TYPE,
REACT_PROFILER_TYPE,
REACT_STRICT_MODE_TYPE,
REACT_SUSPENSE_TYPE,
} from 'shared/ReactSymbols';
import {
cloneElement,
createElement,
isValidElement,
} from './jsx/ReactJSXElement';
import {createRef} from './ReactCreateRef';
import {use, useId, useCallback, useDebugValue, useMemo} from './ReactHooks';
import {forwardRef} from './ReactForwardRef';
import {lazy} from './ReactLazy';
import {memo} from './ReactMemo';
import {cache} from './ReactCacheServer';
import version from 'shared/ReactVersion';

const Children = {
map,
forEach,
count,
toArray,
only,
};

export {
Children,
REACT_FRAGMENT_TYPE as Fragment,
REACT_PROFILER_TYPE as Profiler,
REACT_STRICT_MODE_TYPE as StrictMode,
REACT_SUSPENSE_TYPE as Suspense,
cloneElement,
createElement,
createRef,
use,
forwardRef,
isValidElement,
lazy,
memo,
cache,
useId,
useCallback,
useDebugValue,
useMemo,
version,
};
Loading

0 comments on commit a52cbbc

Please sign in to comment.