Skip to content
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
16 changes: 16 additions & 0 deletions packages/react-reconciler/src/ReactFiberBeginWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,22 @@ function updateActivityComponent(
renderLanes: Lanes,
) {
const nextProps: ActivityProps = workInProgress.pendingProps;
if (__DEV__) {
const hiddenProp = (nextProps: any).hidden;
if (hiddenProp !== undefined) {
console.error(
'<Activity> doesn\'t accept a hidden prop. Use mode="hidden" instead.\n' +
'- <Activity %s>\n' +
'+ <Activity %s>',
hiddenProp === true
? 'hidden'
: hiddenProp === false
? 'hidden={false}'
: 'hidden={...}',
hiddenProp ? 'mode="hidden"' : 'mode="visible"',
);
}
}
const nextChildren = nextProps.children;
const nextMode = nextProps.mode;
const mode = workInProgress.mode;
Expand Down
28 changes: 26 additions & 2 deletions packages/react-reconciler/src/__tests__/Activity-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ describe('Activity', () => {

const root = ReactNoop.createRoot();
await act(() => {
root.render(<Activity hidden={false} />);
root.render(<Activity />);
});
assertLog([]);
expect(root).toMatchRenderedOutput(null);
Expand All @@ -741,7 +741,7 @@ describe('Activity', () => {
// Partially render a component
startTransition(() => {
root.render(
<Activity hidden={false}>
<Activity>
<Child />
<Text text="Sibling" />
</Activity>,
Expand Down Expand Up @@ -1480,4 +1480,28 @@ describe('Activity', () => {
assertLog([]);
expect(root).toMatchRenderedOutput(<span prop={2} />);
});

// @gate enableActivity
it('warns if you pass a hidden prop', async () => {
function App() {
return (
// eslint-disable-next-line react/jsx-boolean-value
<Activity hidden>
<div />
</Activity>
);
}

const root = ReactNoop.createRoot();
await act(() => {
root.render(<App show={true} step={1} />);
});
assertConsoleErrorDev([
'<Activity> doesn\'t accept a hidden prop. Use mode="hidden" instead.\n' +
'- <Activity hidden>\n' +
'+ <Activity mode="hidden">\n' +
' in Activity (at **)\n' +
' in App (at **)',
]);
});
});
Loading