File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change 5
5
[ ![ types] ( https://img.shields.io/npm/types/suspense-service.svg )] [ npm ]
6
6
[ ![ minzipped size] ( https://img.shields.io/bundlephobia/minzip/suspense-service.svg )] [ npm ]
7
7
8
+ [ ![ npm] ( https://nodei.co/npm/suspense-service.png?compact=true )] [ npm ]
9
+
8
10
[ Suspense] integration library for [ React]
9
11
10
12
## Why suspense-service?
@@ -14,19 +16,19 @@ This library aims to provide a generic integration between promise-based data fe
14
16
``` jsx
15
17
import React , { useState , useEffect } from ' react' ;
16
18
17
- const MyComponent = ({ endpoint }) => {
19
+ const MyComponent = ({ request }) => {
18
20
const [data , setData ] = useState ();
19
21
const [loading , setLoading ] = useState (true );
20
22
21
23
useEffect (() => {
22
- const fetchData = async () => {
24
+ const fetchData = async (endpoint ) => {
23
25
const response = await fetch (` /api/v1${ endpoint} ` );
24
26
setData (await response .json ());
25
27
setLoading (false );
26
28
};
27
29
28
- fetchData ();
29
- }, [endpoint ]);
30
+ fetchData (request );
31
+ }, [request ]);
30
32
31
33
if (loading) {
32
34
return (
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " suspense-service" ,
3
- "version" : " 0.2.2 " ,
3
+ "version" : " 0.2.3 " ,
4
4
"description" : " Suspense integration library for React" ,
5
5
"repository" : " github:patrickroberts/suspense-service" ,
6
6
"main" : " dst/cjs/suspense-service.js" ,
You can’t perform that action at this time.
0 commit comments