Skip to content

Commit

Permalink
fix: fix App error when component === false (ant-design#45671)
Browse files Browse the repository at this point in the history
* fix: fix error when component === false

* fix: fix
  • Loading branch information
li-jia-nan authored Nov 5, 2023
1 parent ea25528 commit 3f683d7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion components/app/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,15 @@ describe('App', () => {
});

it('to false', () => {
const warnSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
const { container } = render(
<App component={false}>
<p />
</App>,
);

expect(warnSpy).not.toHaveBeenCalled();
expect(container.querySelector('.ant-app')).toBeFalsy();
warnSpy.mockRestore();
});
});
});
2 changes: 1 addition & 1 deletion components/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const App: React.FC<AppProps> & { useApp: () => useAppProps } = (props) => {
return wrapSSR(
<AppContext.Provider value={memoizedContextValue}>
<AppConfigContext.Provider value={mergedAppConfig}>
<Component {...rootProps}>
<Component {...(component === false ? undefined : rootProps)}>
{ModalContextHolder}
{messageContextHolder}
{notificationContextHolder}
Expand Down

0 comments on commit 3f683d7

Please sign in to comment.