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 69eb50c + b18ed6a commit 2533d2c
Show file tree
Hide file tree
Showing 31 changed files with 161 additions and 66 deletions.
21 changes: 15 additions & 6 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 All @@ -54,8 +61,8 @@ 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
- name: Restore cached node_modules
uses: actions/cache@v4
Expand All @@ -69,6 +76,8 @@ jobs:
with:
path: build
merge-multiple: true
- name: Display structure of build
run: ls -R build
- run: echo ${{ github.sha }} >> build/COMMIT_SHA
- name: Scrape warning messages
run: |
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();
}
Loading

0 comments on commit 2533d2c

Please sign in to comment.