Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ module.exports = function(config) {
transform: [
'babelify'
].concat(args.istanbul && [
['browserify-istanbul', {
ignore: ['**/*.handlebars']
}]
] || [])
['browserify-istanbul', {
ignore: ['**/*.handlebars']
}]
] || [])
},

coverageReporter: {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
"karma-tape-reporter": "^1.0.3",
"minimist": "^1.2.0",
"mocha": "^2.3.3",
"react": "^16.12.0",
"react-addons-test-utils": "^15.0.0-0",
"react": "^15.0.0-0",
"react-dom": "^15.0.0-0"
"react-dom": "^16.12.0"
},
"peerDependencies": {
"react": "^0.14.0 || ^15.0.0 || ^16.0.0"
Expand Down
8 changes: 4 additions & 4 deletions src/Gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ export default class Gateway extends React.Component {
this.gatewayRegistry = context.gatewayRegistry;
}

componentWillMount() {
componentDidMount() {
this.id = this.gatewayRegistry.register(
this.props.into,
this.props.children
);
this.renderIntoGatewayNode(this.props);
}

componentWillReceiveProps(props) {
this.gatewayRegistry.clearChild(this.props.into, this.id);
this.renderIntoGatewayNode(props);
componentDidUpdate(prevProps) {
this.gatewayRegistry.clearChild(prevProps.into, this.id);
this.renderIntoGatewayNode(this.props);
}

componentWillUnmount() {
Expand Down
17 changes: 9 additions & 8 deletions src/GatewayDest.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import GatewayRegistry from './GatewayRegistry';
import {deprecated} from 'react-prop-types';
import { deprecated } from 'react-prop-types';

export default class GatewayDest extends React.Component {
static contextTypes = {
Expand All @@ -11,10 +11,7 @@ export default class GatewayDest extends React.Component {
static propTypes = {
name: PropTypes.string.isRequired,
tagName: deprecated(PropTypes.string, 'Use "component" instead.'),
component: PropTypes.oneOfType([
PropTypes.string,
PropTypes.func
])
component: PropTypes.oneOfType([PropTypes.string, PropTypes.func])
};

constructor(props, context) {
Expand All @@ -26,7 +23,7 @@ export default class GatewayDest extends React.Component {
children: null
};

componentWillMount() {
componentDidMount() {
this.gatewayRegistry.addContainer(this.props.name, this);
}

Expand All @@ -35,8 +32,12 @@ export default class GatewayDest extends React.Component {
}

render() {
const { component, tagName, ...attrs } = this.props;
const {component, tagName, ...attrs} = this.props;
delete attrs.name;
return React.createElement(component || tagName || 'div', attrs, this.state.children);
return React.createElement(
component || tagName || 'div',
attrs,
this.state.children
);
}
}
19 changes: 7 additions & 12 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import {expect} from 'chai';
import { expect } from 'chai';

import React from 'react';
import PropTypes from 'prop-types';
import ReactDOMServer from 'react-dom/server';
import {
Gateway,
GatewayDest,
GatewayProvider,
GatewayRegistry
} from '../src/index.js';
import { Gateway, GatewayDest, GatewayProvider, GatewayRegistry} from '../src/index.js';

function render(jsx) {
return ReactDOMServer.renderToStaticMarkup(jsx);
Expand Down Expand Up @@ -131,7 +126,7 @@ describe('Gateway', function() {
<Gateway into="dest">
<span>{this.textContent}</span>
</Gateway>
);
);
}
}

Expand Down Expand Up @@ -160,7 +155,7 @@ describe('Gateway', function() {
<GatewayDest name="dest"/>
</div>
</GatewayProvider>
);
);
}
}

Expand All @@ -177,13 +172,13 @@ describe('Gateway', function() {
});

describe('GatewayRegistry', function() {
describe('register', function () {
it('should return a gateway id', function () {
describe('register', function() {
it('should return a gateway id', function() {
const gatewayRegistry = new GatewayRegistry();
expect(gatewayRegistry.register('test', <span />)).to.equal('test_0');
});

it('should increment intrernal ids', function () {
it('should increment intrernal ids', function() {
const gatewayRegistry = new GatewayRegistry();
gatewayRegistry.register('test', <span />);
gatewayRegistry.register('test', <span />);
Expand Down
Loading