Giter Site home page Giter Site logo

react-minimalist-portal's Introduction

react-minimalist-portal

A minimalist portal for react. Create a new React tree in document.body to create modal etc .. This package is compatible with react 15 and 16.

npm version npm Build Status Coverage Status

Usage

import React from 'react';
import Portal from 'react-minimalist-portal';

export default class App extends React.Component {
  render() {
    return (
      <Portal>
        <p>I am in document body.</p>
      </Portal>
    );
  }
}

// If you want to render the portal inside your own container
const container = document.getElementById('my-custom-container-id');

export default class App extends React.Component {
  render() {
    return (
      <Portal container={container}>
        <p>I am in my-custom-container-id.</p>
      </Portal>
    );
  }
}

Props

  • container - optional - You can specify a container prop which should be of Element type. The portal will be rendered inside that element. The default behavior will create a div node and render it at the at the end of document.body.

react-minimalist-portal's People

Contributors

afonsovreis avatar amertak avatar bmv437 avatar greenkeeper[bot] avatar itsjw avatar leticiawanderley avatar pradel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-minimalist-portal's Issues

Error when importing in tests

When library is used in node environment (e.g. in tests) you get the following error:

ReferenceError: Element is not defined
    at Object.<anonymous> (....../node_modules/react-minimalist-portal/lib/portal.js:89:45)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)

I'm using mocha to run tests so I can quick fix it with mocking global.Element = null; but not sure it is the best approach.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.