Hook up components
This commit is contained in:
@@ -53,13 +53,15 @@ async function renderApp(res, returnValue, formState) {
|
||||
// const m = require('../src/App.js');
|
||||
const m = await import('../src/App.js')
|
||||
|
||||
const moduleMap = {
|
||||
Text: {
|
||||
id: 'Text',
|
||||
let moduleMap = {}
|
||||
for (let id of Object.keys(await import('../src/client.js'))) {
|
||||
moduleMap[id] = {
|
||||
id,
|
||||
name: 'default',
|
||||
chunks: ['main'],
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
const App = m.default.default || m.default
|
||||
const root = React.createElement(
|
||||
React.Fragment,
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
import * as React from 'react'
|
||||
|
||||
import {Text} from './client.js'
|
||||
import {Label, Stack} from './client.js'
|
||||
|
||||
export default async function App() {
|
||||
return <Text>hello</Text>
|
||||
return (
|
||||
<Stack gap={10}>
|
||||
<Label size={36} lineHeight={1.2} weight="bold" text="Hello, world!" />
|
||||
</Stack>
|
||||
)
|
||||
}
|
||||
|
||||
// TODO
|
||||
|
||||
@@ -1,4 +1,16 @@
|
||||
export const Text = {
|
||||
$$typeof: Symbol.for('react.client.reference'),
|
||||
$$id: 'Text',
|
||||
export const Text = createClientReference('Text')
|
||||
export const ActorLabel = createClientReference('ActorLabel')
|
||||
export const Avatar = createClientReference('Avatar')
|
||||
export const Box = createClientReference('Box')
|
||||
export const Embed = createClientReference('Embed')
|
||||
export const Expandable = createClientReference('Expandable')
|
||||
export const Label = createClientReference('Label')
|
||||
export const Stack = createClientReference('Stack')
|
||||
export const Tabs = createClientReference('Tabs')
|
||||
|
||||
function createClientReference(id) {
|
||||
return {
|
||||
$$typeof: Symbol.for('react.client.reference'),
|
||||
$$id: id,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import React, {Suspense} from 'react'
|
||||
import {useQuery} from '@tanstack/react-query'
|
||||
// @ts-ignore
|
||||
import {createFromFetch} from 'react-server-dom-webpack/client'
|
||||
@@ -23,5 +24,6 @@ export function AppComponent({origin}: {origin: string}) {
|
||||
if (!data) {
|
||||
return null // TODO
|
||||
}
|
||||
return data.root
|
||||
|
||||
return <Suspense fallback={null /* TODO */}>{data.root}</Suspense>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user