diff --git a/examples/react-app/package.json b/examples/react-app/package.json index 561bf9d..ae7e861 100644 --- a/examples/react-app/package.json +++ b/examples/react-app/package.json @@ -6,14 +6,14 @@ "scripts": { "dev": "run-p dev:mock dev:client", "dev:client": "vite --clearScreen=false", - "dev:mock": "prism mock ./petstore.yaml", + "dev:mock": "prism mock ./petstore.yaml --dynamic", "build": "tsc && vite build", "preview": "vite preview", "generate:api": "node ../../dist/src/cli.js -i ./petstore.yaml -c axios --exportSchemas=true --postfixServices=Client --request ./request.ts", "test:generated": "tsc ./openapi/queries/index.ts --noEmit --target esnext --moduleResolution node" }, "dependencies": { - "@tanstack/react-query": "^4.29.7", + "@tanstack/react-query": "^5.0.0", "axios": "^1.4.0", "form-data": "~4.0.0", "react": "^18.2.0", diff --git a/examples/react-app/src/App.tsx b/examples/react-app/src/App.tsx index 6b602fe..207c618 100644 --- a/examples/react-app/src/App.tsx +++ b/examples/react-app/src/App.tsx @@ -2,20 +2,28 @@ import "./App.css"; import { useDefaultClientAddPet, useDefaultClientFindPets, + useDefaultClientFindPetsKey, } from "../openapi/queries"; +import { useState } from 'react'; +import { queryClient } from './queryClient'; function App() { - const { data } = useDefaultClientFindPets( - { tags: [], limit: 10 }, - [], - { - onError: (error) => { - console.error(error); - }, - } + + const [tags, _setTags] = useState([]); + const [limit, _setLimit] = useState(10); + + const { data, error, refetch } = useDefaultClientFindPets( + { tags, limit }, ); - const mutation = useDefaultClientAddPet(); + const { mutate: addPet } = useDefaultClientAddPet(); + + if (error) return ( +
+

Failed to fetch pets

+ +
+ ); return (
@@ -27,12 +35,18 @@ function App() {