Skip to content

Commit

Permalink
add react assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed May 7, 2024
1 parent da02a06 commit 35c0c2b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/e2e/module-layer/middleware.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import 'server-only'
import React from 'react'
import { NextResponse } from 'next/server'
// import './lib/mixed-lib'

export function middleware(request) {
if (React.useState) {
throw new Error('React.useState should not be defined in server layer')
}
return NextResponse.next()
}
4 changes: 4 additions & 0 deletions test/e2e/module-layer/pages/api/hello.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import 'server-only'
import React from 'react'

export default function handler(req, res) {
if (React.useState) {
throw new Error('React.useState should not be defined in server layer')
}
return res.send('pages/api/hello.js:')
}

0 comments on commit 35c0c2b

Please sign in to comment.