# @1productaweek/react-wait-for-window

> Wait for a window prop to become ready (e.g. when loading scriprs async)

Latest version **0.1.0** (published 2020-07-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install @1productaweek/react-wait-for-window
pnpm add @1productaweek/react-wait-for-window
yarn add @1productaweek/react-wait-for-window
bun add @1productaweek/react-wait-for-window
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2020-07-14 |
| First published | 2020-07-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Calum Moore |
| Maintainers | calum.moore |

## Links

- npm: https://www.npmjs.com/package/@1productaweek/react-wait-for-window
- Homepage: https://github.com/1productaweek/react-wait-for-window
- npm.io page: https://npm.io/package/@1productaweek/react-wait-for-window

## Recent versions

- 0.1.0 (latest) — 2020-07-14

## README

# React Wait for Window

Waits for a window prop to become available. E.g. if you're loading Stripe async, you will need to wait for it to become available before trying to use any components that rely on it.

```
npm install @1producataweek/react-wait-for-window
```


### useWaitForWindow(prop: string, timer: number): boolean

A hook that will update when the window prop becomes available. Returns true/false depending on whether the prop is set on `window`. The timer is the interval that the prop should be checked.

```tsx
import { useWaitForWindow } from '@1producataweek/react-wait-for-window'

function Component () {
  const propIsAvailable = useWaitForWindow('stripe', 1000)

  if (!propIsAvailable) return 'Loading'

  return <ComponentThatDependsOnWindowProp />
}
```


### WaitForWindow

A hook that will update when the window prop becomes available. Returns true/false depending on whether the prop is set on `window`. The timer will set 

```tsx
import { WaitForWindow } from '@1producataweek/react-wait-for-window'

function Component () {
  return (
    <WaitForWindow prop='' timer={1000}>
      <ComponentThatDependsOnWindowProp />
    </WaitForWindow>
  )
}
```



### Made by 1PAW

https://1productaweek.com
  |
  |- [Ralley](https://ralley.io) - queue as a service
  |- [Snapboard](https://snapboard.io) - simple hackable dashboard

---
_Source: https://npm.io/package/@1productaweek/react-wait-for-window · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
