Skip to content

Commit

Permalink
Fix ignoring dev warning for preload component (#44065)
Browse files Browse the repository at this point in the history
Fix ignoring warning added in #41519
  • Loading branch information
huozhi committed Dec 16, 2022
1 parent 595ecdb commit 137a63b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/next/server/app-render.tsx
Expand Up @@ -54,7 +54,7 @@ function preloadComponent(Component: any, props: any) {
const prev = console.error
// Hide invalid hook call warning when calling component
console.error = function (msg) {
if (msg.startsWith('Invalid hook call..')) {
if (msg.startsWith('Warning: Invalid hook call.')) {
// ignore
} else {
// @ts-expect-error argument is defined
Expand Down
7 changes: 7 additions & 0 deletions test/e2e/app-dir/index.test.ts
Expand Up @@ -136,8 +136,15 @@ describe('app dir', () => {

if (!(global as any).isNextDeploy) {
it('should serve /index as separate page', async () => {
const stderr = []
next.on('stderr', (err) => {
stderr.push(err)
})
const html = await renderViaHTTP(next.url, '/dashboard/index')
expect(html).toContain('hello from app/dashboard/index')
expect(stderr.some((err) => err.includes('Invalid hook call'))).toBe(
false
)
})

it('should handle next/dynamic correctly', async () => {
Expand Down

0 comments on commit 137a63b

Please sign in to comment.