Installations
npm install react-swr-store
Developer Guide
Typescript
Yes
Module System
ESM
Min. Node Version
>=10
Node Version
19.6.0
NPM Version
lerna/6.5.1/node@v19.6.0+x64 (win32)
Score
67.1
Supply Chain
88.3
Quality
75.8
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Languages
TypeScript (95.54%)
JavaScript (4.46%)
Developer
lxsmnsyc
Download Statistics
Total Downloads
3,774
Last Day
2
Last Week
19
Last Month
68
Last Year
453
GitHub Statistics
7 Stars
134 Commits
3 Watching
1 Branches
1 Contributors
Bundle Size
23.61 kB
Minified
5.84 kB
Minified + Gzipped
Package Meta Information
Latest Version
0.10.6
Package Id
react-swr-store@0.10.6
Unpacked Size
24.21 kB
Size
6.56 kB
File Count
15
NPM Version
lerna/6.5.1/node@v19.6.0+x64 (win32)
Node Version
19.6.0
Publised On
21 Feb 2023
Total Downloads
Cumulative downloads
Total Downloads
3,774
Last day
-60%
2
Compared to previous day
Last week
-44.1%
19
Compared to previous week
Last month
-2.9%
68
Compared to previous month
Last year
-45.6%
453
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
react-swr-store
React bindings for
swr-store
Install
1npm install --save swr-store react-swr-store
1yarn add swr-store react-swr-store
Usage
1import React, { Suspense } from 'react'; 2import { createSWRStore } from 'swr-store'; 3import { useSWRStore, SWRStoreRoot } from 'react-swr-store'; 4 5const API = 'https://dog.ceo/api/breed/'; 6const API_SUFFIX = '/images/random'; 7 8interface APIResult { 9 message: string; 10 status: string; 11} 12 13const dogAPI = createSWRStore<APIResult, [string]>({ 14 key: (breed: string) => breed, 15 get: async (breed: string) => { 16 const response = await fetch(`${API}${breed}${API_SUFFIX}`); 17 return (await response.json()) as APIResult; 18 }, 19 revalidateOnFocus: true, 20 revalidateOnNetwork: true, 21}); 22 23function DogImage(): JSX.Element { 24 const data = useSWRStore(dogAPI, ['shiba'], { 25 suspense: true, 26 }); 27 28 return <img src={data.message} alt={data.message} />; 29} 30 31function Trigger(): JSX.Element { 32 return ( 33 <button 34 type="button" 35 onClick={() => { 36 dogAPI.trigger(['shiba']); 37 }} 38 > 39 Trigger 40 </button> 41 ); 42} 43 44export default function App(): JSX.Element { 45 return ( 46 <SWRStoreRoot> 47 <Trigger /> 48 <div> 49 <Suspense fallback={<h1>Loading...</h1>}> 50 <DogImage /> 51 </Suspense> 52 </div> 53 </SWRStoreRoot> 54 ); 55}
API
<SWRStoreRoot>
Must be located at the root of the app/tree.
useSWRStore(store, args, options)
Subscribes to an SWR store, passing args
, which are received by the corresponding store for data-fetching and cache updates.
options
has the following properties:
suspense
: Whentrue
, suspends the component when receiving the result, if the result status is'pending'
until the result resolves,whereuseSWRStore
returns the resolved data. Otherwise,useSWRStore
returns the result. Defaults tofalse
.initialData
: Allows lazy hydration when reading the store. If the store does not have cache,initialData
hydrates the cache and attempts a revalidation. If noinitialData
is provided, defaults to store'soptions.initialData
.shouldRevalidate
: Iftrue
, goes through the revalidation process when reading through the cache. Defaults totrue
.
License
MIT © lxsmnsyc
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
25 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-wf5p-g6vw-rhxx
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-ghr5-ch3p-vcr6
- Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc
- Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp
- Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-353f-5xf4-qw67
- Warn: Project is vulnerable to: GHSA-c24v-8rfc-w8vw
- Warn: Project is vulnerable to: GHSA-8jhw-289h-jh2g
- Warn: Project is vulnerable to: GHSA-64vr-g452-qvp3
- Warn: Project is vulnerable to: GHSA-9cwx-2883-4wfx
- Warn: Project is vulnerable to: GHSA-vg6x-rcgg-rjx6
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
Score
1.7
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More