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

Remove client caching from cache() API #27977

Merged
merged 3 commits into from
Jan 17, 2024

Commits on Jan 17, 2024

  1. Rewrite cache() tests using Flight

    cache() on the client is not yet stable. It's only stable in Server
    Components. This rewrites the tests to use the Flight renderer instead
    of React Noop.
    
    I also split the cache() tests into a separate module from the tests
    for the <Cache> element, which is a different (experimental) feature.
    acdlite committed Jan 17, 2024
    Configuration menu
    Copy the full SHA
    36a9cba View commit details
    Browse the repository at this point in the history
  2. Rewrite <Cache> element tests to not use cache()

    Because we haven't decided on the client caching semantics of cache(),
    we're going to remove the behavior for now and add it back later. So
    we need to rewrite these client tests to not depend on cache(). This
    essentially reverts the test suite back to what it was before facebook#25506.
    
    There were also some tests in the ReactUse-test module that depended
    on cache() too, which I've also updated.
    acdlite committed Jan 17, 2024
    Configuration menu
    Copy the full SHA
    b8f14f9 View commit details
    Browse the repository at this point in the history
  3. Remove client caching from cache API

    We haven't yet decided how we want `cache` to work on the client. The
    lifetime of the cache is more complex than on the server, where it only
    has to live as long as a single request.
    
    Since it's more important to ship this on the server, we're removing the
    existing behavior from the client for now. On the client (i.e. not a
    Server Components environment) `cache` will have not have any caching
    behavior.
    
    The rest of the behavior is the same as the server implementation — it
    returns a new reference, extra properties like `displayName` are not
    preserved, the length of the new function is 0, etc. That way apps can't
    accidentally depend on those details.
    
    We intend to implement client caching in a future major release. In the
    meantime, it's only exposed as an API so that Shared Components can use
    per-request caching on the server without breaking on the client.
    acdlite committed Jan 17, 2024
    Configuration menu
    Copy the full SHA
    6b66aed View commit details
    Browse the repository at this point in the history