Skip to content

[pull] main from facebook:main #164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 23, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -8344,6 +8344,23 @@ const testsTypescript = {
},
],
},
{
code: normalizeIndent`
function MyComponent(props) {
useEffect(() => {
console.log(props.foo);
});
}
`,
options: [{requireExplicitEffectDeps: true}],
errors: [
{
message:
'React Hook useEffect always requires dependencies. Please add a dependency array or an explicit `undefined`',
suggestions: undefined,
},
],
},
],
};

Expand Down
15 changes: 15 additions & 0 deletions packages/eslint-plugin-react-hooks/src/rules/ExhaustiveDeps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ const rule = {
type: 'string',
},
},
requireExplicitEffectDeps: {
type: 'boolean',
}
},
},
],
Expand All @@ -90,10 +93,13 @@ const rule = {
? rawOptions.experimental_autoDependenciesHooks
: [];

const requireExplicitEffectDeps: boolean = rawOptions && rawOptions.requireExplicitEffectDeps || false;

const options = {
additionalHooks,
experimental_autoDependenciesHooks,
enableDangerousAutofixThisMayCauseInfiniteLoops,
requireExplicitEffectDeps,
};

function reportProblem(problem: Rule.ReportDescriptor) {
Expand Down Expand Up @@ -1340,6 +1346,15 @@ const rule = {
return;
}

if (!maybeNode && isEffect && options.requireExplicitEffectDeps) {
reportProblem({
node: reactiveHook,
message:
`React Hook ${reactiveHookName} always requires dependencies. ` +
`Please add a dependency array or an explicit \`undefined\``
});
}

const isAutoDepsHook =
options.experimental_autoDependenciesHooks.includes(reactiveHookName);

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const SUSPENSE_PENDING_START_DATA = '$?';
const SUSPENSE_QUEUED_START_DATA = '$~';
const SUSPENSE_FALLBACK_START_DATA = '$!';

const SUSPENSEY_FONT_TIMEOUT = 500;

// TODO: Symbols that are referenced outside this module use dynamic accessor
// notation instead of dot notation to prevent Closure's advanced compilation
// mode from renaming. We could use extern files instead, but I couldn't get it
Expand Down Expand Up @@ -251,7 +253,18 @@ export function revealCompletedBoundariesWithViewTransitions(
const transition = (document['__reactViewTransition'] = document[
'startViewTransition'
]({
update: revealBoundaries.bind(null, batch),
update: () => {
revealBoundaries(
batch,
// Force layout to trigger font loading, we pass the actual value to trick minifiers.
document.documentElement.clientHeight,
);
return Promise.race([
// Block on fonts finishing loading before revealing these boundaries.
document.fonts.ready,
new Promise(resolve => setTimeout(resolve, SUSPENSEY_FONT_TIMEOUT)),
]);
},
types: [], // TODO: Add a hard coded type for Suspense reveals.
}));
transition.ready.finally(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/ReactFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export const disableLegacyContext = true;
export const disableLegacyContextForFunctionComponents = true;

// Enable the moveBefore() alternative to insertBefore(). This preserves states of moves.
export const enableMoveBefore = __EXPERIMENTAL__;
export const enableMoveBefore = false;

// Disabled caching behavior of `react/cache` in client runtimes.
export const disableClientCache = true;
Expand Down
Loading