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

Replace server context with AsyncLocalStorage and client context #20

Merged
merged 1 commit into from
Oct 31, 2023

Commits on Oct 31, 2023

  1. Replace server context with AsyncLocalStorage and client context

    Because [server context has been
    deprecated](facebook/react#27424), we needed to
    find a replacement for sharing the current location.
    
    Using conditional exports, we can create a universal `useRouterLocation`
    hook that utilizes `AsyncLocalStorage` on the server, and normal client
    context in the browser. Even though the client context would also be
    accessible in the SSR client (we could render the context provider in
    `ServerRoot`), we are instead using `AsyncLocalStorage` here as well,
    primarily for its convenience. Although this does require placing the
    module containing the `AsyncLocalStorage` instance into a shared webpack
    layer.
    unstubbable committed Oct 31, 2023
    Configuration menu
    Copy the full SHA
    8f840e7 View commit details
    Browse the repository at this point in the history