Skip to content

mosheavni/react-new-window

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React New Window

Pop a new window React using window.open.

Inspired by David Gilbertson's article (must read, must follow).

Features

  • Only 3.3KB (that's 1.4 gzipped!).
  • Support the full window.open api.
  • Built for React 16 (uses ReactDOM.createPortal).
  • Handler for blocked popups (via onBlock prop).
  • Center popups according to the parent window or screen.

Installation

  • npm install react-new-window --save

    or

  • yarn add react-new-window

Usage

import React from 'react'
import NewWindow from 'react-new-window'

const Demo = () => (
  <NewWindow>
    <h1>Hi 👋</h1>
  </NewWindow>
)

Documentation

Properties Type Default Description
url String `` The URL to open, if specified any children will be overriden (more details on url).
name String `` The name of the window (more details on windowName).
title String `` The title of the new window document.
features Object {} The set of window features (more details on windowFeatures).
onUnload Function undefined A function to be triggered before the new window unload.
onBlock Function undefined A function to be triggered when the new window could not be opened.
center String parent Indicate how to center the new window. Valid values are: parent or screen. parent will center the new window according to its parent window. screen will center the new window according to the screen.

Made with :hearth: by Rubens Mariuzzo.

MIT License

About

🔲 Pop new windows in React, using `window.open`.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 97.8%
  • HTML 2.2%