rsnext/test/e2e/app-dir/actions/app/dynamic-csr/csr.js
Shu Ding ad556aee1b
Fix compilation of next/dynamic with ssr: false in App Router (#54411)
For the server compilation, we currently transpile the dynamic import
expression to `null` if `ssr` is disabled. However to make the Server
Actions layer work (as it can be created again from a Client Component),
we can't do that optimization.

This PR changes it to always keep that import expression when
`react_server_components` (App Router) is enabled, no matter which layer
it's on.

Closes #52672.
2023-08-23 14:15:31 +02:00

11 lines
247 B
JavaScript

'use client'
import { inc } from '../client/actions'
import { useState } from 'react'
export function CSR() {
const [count, setCount] = useState(0)
return (
<button onClick={async () => setCount(await inc(count))}>{count}</button>
)
}