TanStack / query

🤖 Powerful asynchronous state management, server-state utilities and data fetching for the web. TS/JS, React Query, Solid Query, Svelte Query and Vue Query.
https://tanstack.com/query
MIT License
42.76k stars 2.92k forks source link

fix(react-query): remove unnecessary code #8015

Closed manudeli closed 2 months ago

manudeli commented 2 months ago

Very small change but this will reduce bundle size

Bundle size diff

"use client";

// src/QueryClientProvider.tsx
import * as React from "react";
import { jsx } from "react/jsx-runtime";
var QueryClientContext = React.createContext(
  void 0
);
var useQueryClient = (queryClient) => {
  const client = React.useContext(QueryClientContext);
  if (queryClient) {
    return queryClient;
  }
  if (!client) {
    throw new Error("No QueryClient set, use QueryClientProvider to set one");
  }
  return client;
};
var QueryClientProvider = ({
  client,
  children
}) => {
  React.useEffect(() => {
    client.mount();
-    return () => {
-      client.unmount();
-    };
+    return client.unmount
  }, [client]);
  return /* @__PURE__ */ jsx(QueryClientContext.Provider, { value: client, children });
};
export {
  QueryClientContext,
  QueryClientProvider,
  useQueryClient
};
//# sourceMappingURL=QueryClientProvider.js.map
nx-cloud[bot] commented 2 months ago

☁️ Nx Cloud Report

CI is running/has finished running commands for commit e84a145f0d8764e1cbad37a046e69cae00d5a06b. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


🟥 Failed Commands
nx affected --targets=test:sherif,test:knip,test:eslint,test:lib,test:types,test:build,build --parallel=3
✅ Successfully ran 1 target - [`nx run-many --target=build --exclude=examples/** --exclude=integrations/**`](https://cloud.nx.app/runs/atzzmxFluH?utm_source=pull-request&utm_medium=comment)

Sent with 💌 from NxCloud.

pkg-pr-new[bot] commented 2 months ago

Open in Stackblitz

More templates

- [@tanstack/query-example-angular-basic](https://pkg.pr.new/template/fa1b1927-d522-40e2-b6d5-e545dcf368a2) - [@tanstack/query-example-angular-infinite-query-with-max-pages](https://pkg.pr.new/template/e469bf0e-d697-4917-81b0-74f97e7f49f5) - [@tanstack/query-example-angular-router](https://pkg.pr.new/template/18473122-38cf-4dcf-88ac-607c2649ec8d) - [@tanstack/query-example-angular-simple](https://pkg.pr.new/template/0a9613ac-2380-4479-a020-bf32c0a429fe) - [@tanstack/query-example-solid-astro](https://pkg.pr.new/template/28002771-0cb0-4a85-92f2-75c49114f9cc) - [@tanstack/query-example-solid-basic](https://pkg.pr.new/template/1db669fe-73c4-4d46-9c1b-acc9dfba7f85) - [@tanstack/query-example-solid-basic-graphql-request](https://pkg.pr.new/template/4dda1f9d-175f-496d-9036-d8aa15389900) - [@tanstack/query-example-solid-default-query-function](https://pkg.pr.new/template/81ecb896-f9a0-4b75-bd8a-43d23c712ab0) - [@tanstack/query-example-solid-simple](https://pkg.pr.new/template/1f7acdcc-ef0a-43b0-b5f8-154f6a400670) - [@tanstack/query-example-solid-start-streaming](https://pkg.pr.new/template/59a6dab3-2560-44c9-9ee5-e7845ebb228a) - [@tanstack/query-example-react-algolia](https://pkg.pr.new/template/cd3a440f-4fb2-437b-bd6e-bfd6509d5ee5) - [@tanstack/query-example-react-auto-refetching](https://pkg.pr.new/template/ebb9d506-27de-4b3d-998c-09dc873f03ee) - [@tanstack/query-example-react-basic](https://pkg.pr.new/template/955a6dee-fcc7-413e-b69f-9dc7e344cabf) - [@tanstack/query-example-react-basic-graphql-request](https://pkg.pr.new/template/7aed8c3d-de9c-4686-8799-dc2a7f80b92a) - [@tanstack/query-example-react-default-query-function](https://pkg.pr.new/template/1fa129d7-6878-457a-8e0d-cb313a1f0b3e) - [@tanstack/query-example-react-devtools-panel](https://pkg.pr.new/template/727ef90d-b4fb-4938-a598-76e5b229123b) - [@tanstack/query-example-react-load-more-infinite-scroll](https://pkg.pr.new/template/5df65603-c36f-4ccb-af68-06e2bbadcb6b) - [@tanstack/query-example-react-infinite-query-with-max-pages](https://pkg.pr.new/template/1fa7b360-9506-4017-9df5-75907f7fa720) - [@tanstack/query-example-react-nextjs](https://pkg.pr.new/template/e521c31a-af39-495c-ab3e-c2e34c20f94e) - [@tanstack/query-example-nextjs-suspense-streaming](https://pkg.pr.new/template/6890b2f1-7950-413f-a94f-c83774bc147d) - [@tanstack/query-example-react-nextjs-app-prefetching](https://pkg.pr.new/template/f9a0c366-b206-4ad8-a2fb-dbfbeea7c8b3) - [@tanstack/query-example-react-optimistic-updates-cache](https://pkg.pr.new/template/746bd98d-c577-4f52-8f3c-afb730525500) - [@tanstack/query-example-react-optimistic-updates-ui](https://pkg.pr.new/template/006322e4-77bc-4ed5-a0a7-e2aec44e73a4) - [@tanstack/query-example-react-offline](https://pkg.pr.new/template/c381ad60-f8e9-4161-a5b2-8e46d0673c0a) - [@tanstack/query-example-react-pagination](https://pkg.pr.new/template/34498bc1-1c59-4d6c-a9d1-98be49ed10d5) - [@tanstack/query-example-react-playground](https://pkg.pr.new/template/37ae33f6-3304-4e3a-b350-7072d28381bf) - [@tanstack/query-example-react-prefetching](https://pkg.pr.new/template/9048e7ec-9238-4f4c-8c38-9528e8104601) - [@tanstack/query-example-react-router](https://pkg.pr.new/template/9927c316-d455-45c0-99df-2d842774f667) - [@tanstack/query-example-react-rick-morty](https://pkg.pr.new/template/b9ca7924-7e45-4d82-809b-2cfbf576ac83) - [@tanstack/query-example-react-react-native](https://pkg.pr.new/template/68e8e763-7c3f-4349-979e-84cf5097d30c) - [@tanstack/query-example-react-shadow-dom](https://pkg.pr.new/template/7700fa2d-3944-4a01-bf1d-7d459dad84a3) - [@tanstack/query-example-react-star-wars](https://pkg.pr.new/template/31e6c08e-9ef1-459e-ac4a-a6b58b976357) - [@tanstack/query-example-react-simple](https://pkg.pr.new/template/74342834-9119-4ab4-9317-c23f87438256) - [@tanstack/query-example-react-suspense](https://pkg.pr.new/template/37960352-3c37-45b3-ab38-befba55b2463) - [@tanstack/query-example-svelte-auto-refetching](https://pkg.pr.new/template/59f69304-acfc-485c-80f1-8e150d1b6c03) - [@tanstack/query-example-svelte-basic](https://pkg.pr.new/template/d2aa08fa-7dfe-47a5-a00b-996815d5bd0e) - [@tanstack/query-example-svelte-optimistic-updates](https://pkg.pr.new/template/ccff4ad3-c8c9-461d-a529-1593b3dcfa61) - [@tanstack/query-example-svelte-load-more-infinite-scroll](https://pkg.pr.new/template/301d0c5f-1494-4c0b-8911-0e61089a26dc) - [@tanstack/query-example-svelte-playground](https://pkg.pr.new/template/2a000e10-6e1f-4200-8596-159e77893146) - [@tanstack/query-example-svelte-simple](https://pkg.pr.new/template/28404079-ffe0-4b70-a39c-bc20afb6dfb2) - [@tanstack/query-example-svelte-ssr](https://pkg.pr.new/template/b767f5f6-5c97-43a5-9e32-b12bb6c6e759) - [@tanstack/query-example-svelte-star-wars](https://pkg.pr.new/template/0446d0b8-1f12-4951-8a88-43a913939d6a) - [@tanstack/query-example-vue-2.7-basic](https://pkg.pr.new/template/c5851226-c4c4-4117-8bee-dcddef22147e) - [@tanstack/query-example-vue-2.6-basic](https://pkg.pr.new/template/d80bfd75-92bb-4964-b873-4991f1285a82) - [@tanstack/query-example-vue-basic](https://pkg.pr.new/template/1ef822d8-246b-4c9a-bdd1-10e841b11ed4) - [@tanstack/query-example-vue-nuxt3](https://pkg.pr.new/template/5e9f338b-17ef-4335-bf62-3dac2d3691a0) - [@tanstack/query-example-vue-dependent-queries](https://pkg.pr.new/template/a8510c73-4791-4fe1-9f8a-6df12192d0ef) - [@tanstack/query-example-vue-persister](https://pkg.pr.new/template/1280c0c0-83b5-4613-9156-1db4e4d70aa3) - [@tanstack/query-example-vue-simple](https://pkg.pr.new/template/caa7d63b-552c-42d7-9ba8-d67cc5720c4a)

@tanstack/angular-query-devtools-experimental

``` pnpm add https://pkg.pr.new/@tanstack/angular-query-devtools-experimental@8015 ```

@tanstack/angular-query-experimental

``` pnpm add https://pkg.pr.new/@tanstack/angular-query-experimental@8015 ```

@tanstack/eslint-plugin-query

``` pnpm add https://pkg.pr.new/@tanstack/eslint-plugin-query@8015 ```

@tanstack/query-async-storage-persister

``` pnpm add https://pkg.pr.new/@tanstack/query-async-storage-persister@8015 ```

@tanstack/query-broadcast-client-experimental

``` pnpm add https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@8015 ```

@tanstack/query-core

``` pnpm add https://pkg.pr.new/@tanstack/query-core@8015 ```

@tanstack/query-devtools

``` pnpm add https://pkg.pr.new/@tanstack/query-devtools@8015 ```

@tanstack/query-persist-client-core

``` pnpm add https://pkg.pr.new/@tanstack/query-persist-client-core@8015 ```

@tanstack/query-sync-storage-persister

``` pnpm add https://pkg.pr.new/@tanstack/query-sync-storage-persister@8015 ```

@tanstack/react-query

``` pnpm add https://pkg.pr.new/@tanstack/react-query@8015 ```

@tanstack/react-query-next-experimental

``` pnpm add https://pkg.pr.new/@tanstack/react-query-next-experimental@8015 ```

@tanstack/react-query-devtools

``` pnpm add https://pkg.pr.new/@tanstack/react-query-devtools@8015 ```

@tanstack/react-query-persist-client

``` pnpm add https://pkg.pr.new/@tanstack/react-query-persist-client@8015 ```

@tanstack/solid-query

``` pnpm add https://pkg.pr.new/@tanstack/solid-query@8015 ```

@tanstack/solid-query-devtools

``` pnpm add https://pkg.pr.new/@tanstack/solid-query-devtools@8015 ```

@tanstack/svelte-query

``` pnpm add https://pkg.pr.new/@tanstack/svelte-query@8015 ```

@tanstack/solid-query-persist-client

``` pnpm add https://pkg.pr.new/@tanstack/solid-query-persist-client@8015 ```

@tanstack/svelte-query-devtools

``` pnpm add https://pkg.pr.new/@tanstack/svelte-query-devtools@8015 ```

@tanstack/svelte-query-persist-client

``` pnpm add https://pkg.pr.new/@tanstack/svelte-query-persist-client@8015 ```

@tanstack/vue-query

``` pnpm add https://pkg.pr.new/@tanstack/vue-query@8015 ```

@tanstack/vue-query-devtools

``` pnpm add https://pkg.pr.new/@tanstack/vue-query-devtools@8015 ```

commit: e84a145

TkDodo commented 2 months ago

client is a class so I think this won't work because of this bindings

TkDodo commented 2 months ago

the test failures confirm this.