Comparing version 0.1.88 to 0.1.89
{ | ||
"name": "use-http", | ||
"version": "0.1.88", | ||
"version": "0.1.89", | ||
"homepage": "http://use-http.com", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -75,2 +75,3 @@ <a href="http://use-http.com"> | ||
- Request/response interceptors <!--https://github.com/alex-cory/use-http#user-content-interceptors--> | ||
- React Native support | ||
@@ -100,6 +101,5 @@ Usage | ||
useEffect(() => { | ||
if (!mounted.current) { | ||
initializeTodos() | ||
mounted.current= true | ||
} | ||
if (mounted.current) return | ||
mounted.current= true | ||
initializeTodos() | ||
}) | ||
@@ -124,3 +124,3 @@ | ||
{request.loading && 'Loading...'} | ||
{todos.length > 0 && todos.map(todo => ( | ||
{todos.map(todo => ( | ||
<div key={todo.id}>{todo.title}</div> | ||
@@ -151,3 +151,3 @@ )} | ||
{loading && 'Loading...'} | ||
{!loading && data.map(todo => ( | ||
{data.map(todo => ( | ||
<div key={todo.id}>{todo.title}</div> | ||
@@ -177,3 +177,3 @@ )} | ||
{loading && 'Loading...'} | ||
{!loading && data.map(todo => ( | ||
{data.map(todo => ( | ||
<div key={todo.id}>{todo.title}</div> | ||
@@ -561,3 +561,2 @@ )} | ||
- [ ] make this a github package | ||
- [ ] react native support | ||
- [ ] Make work with React Suspense [current example WIP](https://codesandbox.io/s/7ww5950no0) | ||
@@ -571,10 +570,13 @@ - [ ] get it all working on a SSR codesandbox, this way we can have api to call locally | ||
- [ ] Cache responses to improve speed and reduce amount of requests | ||
- [ ] maybe add syntax for inline headers like this | ||
- [ ] maybe add syntax for middle helpers for inline `headers` or `queries` like this: | ||
```jsx | ||
const user = useFetch() | ||
const request = useFetch('https://example.com') | ||
user | ||
request | ||
.headers({ | ||
auth: jwt | ||
auth: jwt // this would inline add the `auth` header | ||
}) | ||
.query({ | ||
no: 'way' // this would inline make the url: https://example.com?no=way | ||
}) | ||
.get() | ||
@@ -603,2 +605,3 @@ ``` | ||
onTimeout: () => {}, // called when the last `retry` is made and times out | ||
onAbort: () => {}, // called when aborting the request | ||
onServer: true, // potential idea to fetch on server instead of just having `loading` state. Not sure if this is a good idea though | ||
@@ -605,0 +608,0 @@ query: `some graphql query` // if you would prefer to pass the query in the config |
74441
676