# react-use-query-timeout

> React Simple use query graphql with timeout. (react-hook)

Latest version **2.0.0** (published 2022-05-28) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install react-use-query-timeout
pnpm add react-use-query-timeout
yarn add react-use-query-timeout
bun add react-use-query-timeout
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2022-05-28 |
| First published | 2022-05-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 10 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Delpi.Kye |
| Maintainers | delpikye |
| Keywords | react, react-lib, use-query, use-query-timeout, use-query-graphql, query-timeout, query-graphql |

## Links

- npm: https://www.npmjs.com/package/react-use-query-timeout
- Repository: https://github.com/delpikye-v/react-use-query-timeout
- Homepage: https://github.com/delpikye-v/react-use-query-timeout#readme
- Issues: https://github.com/delpikye-v/react-use-query-timeout/issues
- npm.io page: https://npm.io/package/react-use-query-timeout

## Dependencies (1)

- [@apollo/client](https://npm.io/package/@apollo/client.md) ^3.6.5

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2022-05-28

## README

<div align="center">
    <h1>react-use-query-timeout</h1>
    <br />
    <a href="https://codesandbox.io/s/uu5etr">LIVE EXAMPLE</a>
</div>

---

#### Description

+ Simple use query graphql (react-hook) with timeout.
+ Default timeout 10m
+ From @apollo/client :v

---

#### Usage
```js
npm install react-use-query-timeout
```

Import the module in the place you want to use:
```js

import { useQueryTimeout } from 'react-use-query-timeout'
```


#### Snippet

##### `simple`

```js
    const [request, setRequest] = useState<number | boolean | string>(0);
     // start request in { true | number !== 0 | string !== empty }

    const { data: queryData, loading, isRequestTimeout, error } = useQueryTimeout(QUERY, {
        variables: {
          start: xxx,
          end: xxx,
          ...
        },
        timeout: 60 * 1000, // 60s
        flagNewQuery: request,
        clearFlagNewQuery: setRequest
    });

    useEffect(() => {
        if (!loading) {
            console.log(queryData, loading, isRequestTimeout, error)
            debugger
        }
    }, [loading])


    // => change it => auto make new query
    <Button onClick={() => setRequest(+ new Date())}>Abcd</Button>
```

<br />

##### `simple`

```js

    const { fetchQuery } = useQueryTimeout(QUERY, {
        variables: {
          start: xxx,
          end: xxx,
          ...
        },
        timeout: 60 * 1000, // 60s
    });

    const handlerAbc = () => {
        fetchQuery().then((rresult) => {
            console.log(rresult) // rresult.data | error | { isRequestTimeout }
            debugger
        })
    }


    <Button onClick={() => handlerAbc()}>Abcd</Button>
```
<br />

---

#### props


<br />

#### RUN

<a href="https://codesandbox.io/s/uu5etr">LIVE EXAMPLE</a>

```js
npm install
```
```js
npm run dev
npm run start
```

### License

MIT

---
_Source: https://npm.io/package/react-use-query-timeout · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
