rsnext/test/integration/react-streaming-and-server-components/app/components/shared.js
Shu Ding 8ba2aec022
Fix flight loader for shared components (#34692)
* fix flight loader for shared components

* add tests

* fix condition
2022-02-28 16:00:28 +01:00

21 lines
409 B
JavaScript

import { useState } from 'react'
import Client from './client.client'
const random = ~~(Math.random() * 10000)
export default function Shared() {
let isServerComponent
try {
useState()
isServerComponent = false
} catch (e) {
isServerComponent = true
}
return (
<>
<Client />,{' '}
{(isServerComponent ? 'shared:server' : 'shared:client') + ':' + random}
</>
)
}