Skip to content

(build-only) Objects are not valid as a React child #1496

@himself65

Description

@himself65

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;
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions