Socket
Socket
Sign inDemoInstall

react-portal

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-portal - npm Package Compare versions

Comparing version 0.5.1 to 0.6.0

17

examples/index.js

@@ -10,3 +10,6 @@ var React = require('react');

getInitialState: function() {
return {isPortalOpened: false};
return {
isPortalOpened: false,
someValue: 'init'
};
},

@@ -28,3 +31,3 @@

<Portal closeOnEsc={true} openByClickOn={button1}>
<Portal closeOnEsc={true} openByClickOn={button1} testProp={this.state.someValue}>
<PseudoModal>

@@ -42,3 +45,3 @@ <h2>Pseudo Modal</h2>

</button>
<Portal isOpened={this.state.isPortalOpened}>
<Portal isOpened={this.state.isPortalOpened} testProp={this.state.someValue}>
<LoadingBar />

@@ -53,2 +56,6 @@ </Portal>

<button onClick={this.changeValue}>
Change randomly value: {this.state.someValue}
</button>
</div>

@@ -60,2 +67,6 @@ );

this.setState({isPortalOpened: !this.state.isPortalOpened});
},
changeValue: function(e) {
this.setState({someValue: Math.random().toString(36).substring(7)});
}

@@ -62,0 +73,0 @@

18

lib/portal.js

@@ -35,5 +35,10 @@ import React, {findDOMNode} from 'react';

componentWillReceiveProps(newProps) {
if (newProps.isOpened !== 'undefined' && this.newProps !== this.props) {
if (newProps.isOpened && !this.state.active) {
this.openPortal();
// portal's 'is open' state is handled through the prop isOpened
if (typeof newProps.isOpened !== 'undefined') {
if (newProps.isOpened) {
if (this.state.active) {
this.renderPortal(newProps);
} else {
this.openPortal();
}
}

@@ -44,2 +49,7 @@ if (!newProps.isOpened && this.state.active) {

}
// portal handles its own 'is open' state
if (typeof newProps.isOpened === 'undefined' && this.state.active) {
this.renderPortal(newProps);
}
}

@@ -118,3 +128,3 @@

// ESC
if (e.keyCode === 27) {
if (e.keyCode === 27 && this.state.active) {
this.closePortal();

@@ -121,0 +131,0 @@ }

@@ -6,3 +6,3 @@ {

"author": "Vojtech Miksu",
"version": "0.5.1",
"version": "0.6.0",
"license": "MIT",

@@ -9,0 +9,0 @@ "repository": {

@@ -66,5 +66,10 @@ 'use strict';

value: function componentWillReceiveProps(newProps) {
if (newProps.isOpened !== 'undefined' && this.newProps !== this.props) {
if (newProps.isOpened && !this.state.active) {
this.openPortal();
// portal's 'is open' state is handled through the prop isOpened
if (typeof newProps.isOpened !== 'undefined') {
if (newProps.isOpened) {
if (this.state.active) {
this.renderPortal(newProps);
} else {
this.openPortal();
}
}

@@ -75,2 +80,7 @@ if (!newProps.isOpened && this.state.active) {

}
// portal handles its own 'is open' state
if (typeof newProps.isOpened === 'undefined' && this.state.active) {
this.renderPortal(newProps);
}
}

@@ -164,3 +174,3 @@ }, {

// ESC
if (e.keyCode === 27) {
if (e.keyCode === 27 && this.state.active) {
this.closePortal();

@@ -167,0 +177,0 @@ }

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc