Files
295f9da393 Client directive (#40415)
## Feature
Change server components convention from using `.server.js` / `.client.js` file extension to determine it's a server or client component to using `'client'` js literal as a directive for determine client components boundary.
React RFC: https://github.com/reactjs/rfcs/pull/189
New behavior doesn't consume `.server.js` as server components any more, if you're enabling `serverComponents` flag, every `page.js` in app dir will become server components by default. If you adding a `'client'` directive to the page, then that page will become a client component. This rule also applies to the normal js components, client components will require a `'client'` directive to indicate its identity, instead of having a `.client.js` extension.
- [x] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

Co-authored-by: Shu Ding <[email protected]>
2022-09-18 00:00:16 +00:00

33 lines
618 B
JavaScript

import { Suspense } from 'react'
import Nav from '../../components/nav'
let result
let promise
function Data() {
if (result) return result
if (!promise)
promise = new Promise((res) => {
setTimeout(() => {
result =
'</script><script>window.__manipulated_by_injection=true</script><script>'
res()
}, 500)
})
throw promise
}
export default function Page() {
return (
<div>
<div id="content">
<Suspense fallback="next_escaping_fallback">
<Data />
</Suspense>
</div>
<div>
<Nav />
</div>
</div>
)
}