# handle-window-undefined

> Example Button Component

Latest version **0.0.6** (published 2023-09-05) · 0 weekly downloads

## Install

```sh
npm install handle-window-undefined
pnpm add handle-window-undefined
yarn add handle-window-undefined
bun add handle-window-undefined
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2023-09-05 |
| First published | 2020-06-10 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 6 |
| Unpacked size | 5.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Yogesh DV |
| Maintainers | dv_yogesh |
| Keywords | handle window undefined, solve window undefined, window undefined, js |

## Links

- npm: https://www.npmjs.com/package/handle-window-undefined
- npm.io page: https://npm.io/package/handle-window-undefined

## Dependencies (6)

- [react](https://npm.io/package/react.md) ^16.8.0
- [convert-fetch-to-curl](https://npm.io/package/convert-fetch-to-curl.md) ^0.0.4
- [parse-url-query-params](https://npm.io/package/parse-url-query-params.md) ^0.0.8
- [handle-window-undefined](https://npm.io/package/handle-window-undefined.md) ^0.0.6
- [disable-snapshot-testing](https://npm.io/package/disable-snapshot-testing.md) ^0.0.7
- [react-window-dimensions-hook](https://npm.io/package/react-window-dimensions-hook.md) ^0.0.7

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.0.6 (latest) — 2023-09-05
- 0.0.5 — 2023-09-05
- 0.0.4 — 2020-07-24
- 0.0.3 — 2020-06-10
- 0.0.2 — 2020-06-10

## README

[![GitHub license](https://img.shields.io/github/license/x3388638/react-grid-carousel)](https://github.com/x3388638/react-grid-carousel/blob/master/LICENSE) [![npm version](https://badge.fury.io/js/react-grid-carousel.svg)](https://badge.fury.io/js/react-grid-carousel) [![Open Source](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://opensource.org/)


Demo: https://dvyogesh.github.io/lerna-starter/?path=/story/design-system-window-handle--window-handle

<h1 align="center">handle window undefined Error </h1>
will helps to solve <span style={{color:'red'}}>window undefined</span> or <span style={{color:'red'}}> undefined of window </span>. This error mostly comes in node js application at the time when you are trying to run browser object in server side.
<p> </p>
`handle-window-undefined` is a powerful and lightweight, flexible ES6 JavaScript library 


## Features

- Server side rendering
- light waight


## Install

```bash
$ npm install handle-window-undefined --save

$ yarn add handle-window-undefined
```

## Usage

Just import the `window` component from `handle-window-undefined`  

```javascript
import window from 'handle-window-undefined';
// we can access any function related to window object 
// like window.addEventListener, window.matchMedia, window.location ...etc
    
console.log(window)

```

#### -- OR --

##### Simple DOM Example

Just import the `GridCarousel` component from `handle-window-undefined`  
and pass your item as childrens


```javascript
import window from 'handle-window-undefined';
 
window.document.body.innerHTML = '<div class="foo">Hi!</div>';
window.document.body.querySelector('.foo').textContent;
```


## Another  Example with react

in this way we can avoid window undefined error while add `window.addEventListener`
```javascript
import React,{useEffect} from 'react';
import window from 'handle-window-undefined';

const WindowExample = () => {

  useEffect(()=>{
    window.addEventListener('click', ()=>{})
  })
}

export default WindowExample;

```

or visit https://dvyogesh.github.io/lerna-starter/?path=/story/design-system-window-handle--window-handle


## Universal Testing Pattern 

You can use a really simple pattern to enable your browser modules to run in Node.js. Just allow a window object to be passed in to your module and prepend any references to browser globals with win. Set win to the passed in window object if it exists, otherwise fallback to global window.

```javascript

  import window from 'handle-window-undefined'

  function createTitle(text, win) {
    win = win || (typeof window === 'undefined' ? undefined : window);
  
    const title = win.document.createElement('h1');
    title.innerHTML = text;
    return title;
  };
 
  module.exports = createTitle;
```






or visit https://dvyogesh.github.io/lerna-starter/?path=/story/design-system-window-handle--window-handle



## LICENSE

MIT

---
_Source: https://npm.io/package/handle-window-undefined · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
