waku: (build-only) Objects are not valid as a React child
See: https://github.com/wakujs/ssr-benchmark
npm i
cd modules/waku
npm i
npm run start
Error: Objects are not valid as a React child (found: object with keys {$$typeof, type, key, ref, props, _owner, _store}). If you meant to render a collection of children, use an array instead.
at retryNode (file:///Users/himself65/Code/ssr-benchmark/modules/waku/dist/ssr/rd-server.js:3761:15)
at renderNodeDestructive (file:///Users/himself65/Code/ssr-benchmark/modules/waku/dist/ssr/rd-server.js:3581:237)
at renderNode (file:///Users/himself65/Code/ssr-benchmark/modules/waku/dist/ssr/rd-server.js:3922:16)
at renderChildrenArray (file:///Users/himself65/Code/ssr-benchmark/modules/waku/dist/ssr/rd-server.js:3831:93)
at retryNode (file:///Users/himself65/Code/ssr-benchmark/modules/waku/dist/ssr/rd-server.js:3736:11)
at renderNodeDestructive (file:///Users/himself65/Code/ssr-benchmark/modules/waku/dist/ssr/rd-server.js:3581:237)
at renderNode (file:///Users/himself65/Code/ssr-benchmark/modules/waku/dist/ssr/rd-server.js:3922:16)
at renderChildrenArray (file:///Users/himself65/Code/ssr-benchmark/modules/waku/dist/ssr/rd-server.js:3831:93)
at retryNode (file:///Users/himself65/Code/ssr-benchmark/modules/waku/dist/ssr/rd-server.js:3736:11)
at renderNodeDestructive (file:///Users/himself65/Code/ssr-benchmark/modules/waku/dist/ssr/rd-server.js:3581:237)
testdata type
export const testData: () => Promise<{ id: string; name: string }[]>;
table.tsx
import { testData } from "testdata";
import { use } from "react";
export function Table({ data }: { data: ReturnType<typeof testData> }) {
const tdata = use(data);
return (
<table>
<tbody>
{tdata.map((entry) => (
<Entry key={entry.id} entry={entry} />
))}
</tbody>
</table>
);
}
function Entry(props: {
entry: { id: string; name: string; asyncData?: () => Promise<string> };
}) {
return (
<tr>
<td>{props.entry.id}</td>
<td>{props.entry.name}</td>
</tr>
);
}
_layout.tsx
import type { ReactNode } from "react";
type RootLayoutProps = { children: ReactNode };
export default async function RootLayout({ children }: RootLayoutProps) {
return children;
}
export const getConfig = async () => {
return {
render: "static",
} as const;
};
index.tsx
import { Suspense } from "react";
import { testData } from "testdata";
import { Table } from "../components/table";
function App() {
const data = testData()
return (
<Suspense>
<Table data={data} />
</Suspense>
);
}
export default App;
export const getConfig = async () => {
return {
render: "static",
} as const;
};
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 16 (16 by maintainers)
I’ve reported an issue https://github.com/facebook/react/issues/33937. Maybe it was a bad timing. Someone just spammed their issue tracker today 🫠
I’ll probably dig into React, but there might be a workaround by implementing
useon user land. See https://github.com/wakujs/waku/pull/1542Forgot to link, but a standalone minimal repro is here https://github.com/hi-ogawa/reproductions/tree/main/waku-1496-react-use-mixed-up
@himself65 I added some commits and tests are passing. Can you check it please?
https://github.com/wakujs/waku/pull/1498