@aspida/swr
Advanced tools
Comparing version 1.12.0 to 1.13.0
{ | ||
"name": "@aspida/swr", | ||
"version": "1.12.0", | ||
"version": "1.13.0", | ||
"description": "SWR wrapper for aspida", | ||
"author": "Solufa <solufa2020@gmail.com>", | ||
"license": "MIT", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"main": "./dist/cjs/index.js", | ||
"module": "./dist/esm/index.js", | ||
"bin": "./bin/index.js", | ||
"exports": { | ||
".": { | ||
"require": "./dist/cjs/index.js", | ||
"import": "./dist/esm/index.js", | ||
"types": "./dist/esm/index.d.ts" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"homepage": "https://github.com/aspida/aspida/tree/master/packages/aspida-swr#readme", | ||
@@ -29,4 +38,4 @@ "repository": { | ||
"dependencies": { | ||
"aspida": "^1.12.0" | ||
"aspida": "^1.13.0" | ||
} | ||
} | ||
} |
@@ -12,8 +12,2 @@ # @aspida/swr | ||
</a> | ||
<a href="https://github.com/aspida/aspida/actions?query=workflow%3A%22Node.js+CI%22"> | ||
<img src="https://github.com/aspida/aspida/workflows/Node.js%20CI/badge.svg?branch=master" alt="Node.js CI" /> | ||
</a> | ||
<a href="https://lgtm.com/projects/g/aspida/aspida/context:javascript"> | ||
<img src="https://img.shields.io/lgtm/grade/javascript/g/aspida/aspida.svg" alt="Language grade: JavaScript" /> | ||
</a> | ||
</div> | ||
@@ -50,14 +44,14 @@ <br /> | ||
```tsx | ||
import useAspidaSWR from "@aspida/swr" | ||
import aspida from "@aspida/axios" // "@aspida/fetch", "@aspida/node-fetch" | ||
import api from "../api/$api" | ||
import aspida from "@aspida/axios"; // "@aspida/fetch", "@aspida/node-fetch" | ||
import useAspidaSWR from "@aspida/swr"; | ||
import api from "../api/$api"; | ||
const client = api(aspida()) | ||
const client = api(aspida()); | ||
function Profile() { | ||
const { data, error } = useAspidaSWR(client.user._userId(123), { query: { name: "mario" } }) | ||
const { data, error } = useAspidaSWR(client.user._userId(123), { query: { name: "mario" } }); | ||
if (error) return <div>failed to load</div> | ||
if (!data) return <div>loading...</div> | ||
return <div>hello {data.name}!</div> | ||
if (error) return <div>failed to load</div>; | ||
if (!data) return <div>loading...</div>; | ||
return <div>hello {data.name}!</div>; | ||
} | ||
@@ -71,15 +65,15 @@ ``` | ||
```tsx | ||
import useAspidaSWR from "@aspida/swr" | ||
import aspida from "@aspida/axios" // "@aspida/fetch", "@aspida/node-fetch" | ||
import api from "../api/$api" | ||
import aspida from "@aspida/axios"; // "@aspida/fetch", "@aspida/node-fetch" | ||
import useAspidaSWR from "@aspida/swr"; | ||
import api from "../api/$api"; | ||
const client = api(aspida()) | ||
const client = api(aspida()); | ||
function Profile() { | ||
const { data, error } = useAspidaSWR(client.user._userId(123), "get", { | ||
query: { name: "mario" } | ||
}) | ||
query: { name: "mario" }, | ||
}); | ||
if (error) return <div>failed to load</div> | ||
if (!data) return <div>loading...</div> | ||
if (error) return <div>failed to load</div>; | ||
if (!data) return <div>loading...</div>; | ||
return ( | ||
@@ -91,3 +85,3 @@ <> | ||
</> | ||
) | ||
); | ||
} | ||
@@ -103,7 +97,7 @@ ``` | ||
```tsx | ||
import useAspidaSWR from "@aspida/swr" | ||
import aspida from "@aspida/axios" // "@aspida/fetch", "@aspida/node-fetch" | ||
import api from "../api/$api" | ||
import aspida from "@aspida/axios"; // "@aspida/fetch", "@aspida/node-fetch" | ||
import useAspidaSWR from "@aspida/swr"; | ||
import api from "../api/$api"; | ||
const client = api(aspida()) | ||
const client = api(aspida()); | ||
@@ -114,7 +108,7 @@ function Profile() { | ||
revalidateOnMount: true, | ||
initialData: { name: "anonymous" } | ||
}) | ||
initialData: { name: "anonymous" }, | ||
}); | ||
if (error) return <div>failed to load</div> | ||
return <div>hello {data.name}!</div> | ||
if (error) return <div>failed to load</div>; | ||
return <div>hello {data.name}!</div>; | ||
} | ||
@@ -128,7 +122,7 @@ ``` | ||
```ts | ||
const { data: user } = useAspidaSWR(client.user) | ||
const { data: user } = useAspidaSWR(client.user); | ||
const { data } = useAspidaSWR(client.articles, { | ||
query: { userId: user?.id ?? 0 }, | ||
enabled: !!user | ||
}) | ||
enabled: !!user, | ||
}); | ||
// is an alias of | ||
@@ -138,3 +132,3 @@ const { data } = useSWR( | ||
() => client.articles.$get({ query: { userId: user.id } }) | ||
) | ||
); | ||
``` | ||
@@ -141,0 +135,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21112
11
136
131
1
Updatedaspida@^1.13.0