0.0.0 • Published 6 years ago

react-window-portal v0.0.0

Weekly downloads
8
License
MIT
Repository
github
Last release
6 years ago

React Window Portal

styled with prettier Greenkeeper badge Travis Coveralls Dev Dependencies

React Portal to a new window.

Inspired by Using a React 16 Portal to do something cool.

Example

import { WindowPortal } from "react-window-portal";

export class MyComponent extends React.PureComponent<{}, { isOpen: boolean }> {
    public state = {
        isOpen: false,
    };

    public render() {
        return (
            <div>
                <button onClick={() => this.setState({ isOpen: true })}>open window</button>
                {this.state.isOpen && (
                    <WindowPortal width={500} height={500}>
                        <button onClick={() => this.setState({ isOpen: false })}>close window</button>
                    </WindowPortal>
                )}
            </div>
        );
    }
}

Developing

git clone https://github.com/mscolnick/react-window-portal.git
yarn

NPM scripts

  • yarn test: Run test suite
  • yarn start: Run yarn run build in watch mode
  • yarn test:watch: Run test suite in interactive watch mode
  • yarn test:prod: Run linting and generate coverage
  • yarn build: Generate bundles and typings, create docs
  • yarn lint: Lints code
  • yarn commit: Commit using conventional commit style (husky will tell you to use it if you haven't :wink:)