Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example with Remix + React18 #3

Open
HuyAms opened this issue Nov 22, 2023 · 2 comments
Open

Example with Remix + React18 #3

HuyAms opened this issue Nov 22, 2023 · 2 comments

Comments

@HuyAms
Copy link

HuyAms commented Nov 22, 2023

Hi, could you add an example of how it works in React18?

Example of the new Remix entry.server.tsx can be found here: https://github.com/epicweb-dev/epic-stack/blob/main/app/entry.server.tsx

Here is what I've tried but it doesn't seem to work

function handleBrowserRequest(
  request: Request,
  responseStatusCode: number,
  responseHeaders: Headers,
  remixContext: EntryContext
) {
  return new Promise((resolve, reject) => {
    let shellRendered = false;
    const { pipe, abort } = renderToPipeableStream(
      <RemixServer
        context={remixContext}
        url={request.url}
        abortDelay={ABORT_DELAY}
      />,
      {
        onShellReady() {
          shellRendered = true;
          const body = new PassThrough();
          const stream = createReadableStreamFromReadable(body);

          responseHeaders.set("Content-Type", "text/html");

          const response =  new Response(stream, {
            headers: responseHeaders,
            status: responseStatusCode,
          })


          resolve(
           👉 etag({ request, response })
          );

          pipe(body);
        },
        onShellError(error: unknown) {
          ..
        },
        onError(error: unknown) {
        ...
        },
      }
    );

    setTimeout(abort, ABORT_DELAY);
  });
}
@gonstoll
Copy link

gonstoll commented Apr 1, 2024

@HuyAms did you have any luck figuring this out? I'm stuck in the same place 😕

@gonstoll
Copy link

gonstoll commented Apr 1, 2024

@HuyAms in case you didn't figure it out, here is the solution: remix-run/remix#9174

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants