Skip to content
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

Fix ignoring dev warning for preload component #44065

Merged
merged 3 commits into from Dec 16, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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