Skip to content

Commit

Permalink
Only create divs when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulLeCam committed Nov 12, 2016
1 parent 4f19057 commit 956eca0
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
4 changes: 2 additions & 2 deletions dist/react-leaflet.js
Original file line number Diff line number Diff line change
Expand Up @@ -2521,11 +2521,11 @@ return /******/ (function(modules) { // webpackBootstrap
};

MapLayer.prototype.render = function render() {
return _react2.default.createElement(
return Array.isArray(this.props.children) ? _react2.default.createElement(
'div',
{ style: { display: 'none' } },
this.props.children
);
) : this.props.children || null;
};

_createClass(MapLayer, [{
Expand Down
4 changes: 2 additions & 2 deletions dist/react-leaflet.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lib/MapLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ var MapLayer = function (_MapComponent) {
};

MapLayer.prototype.render = function render() {
return _react2.default.createElement(
return Array.isArray(this.props.children) ? _react2.default.createElement(
'div',
{ style: { display: 'none' } },
this.props.children
);
) : this.props.children || null;
};

_createClass(MapLayer, [{
Expand Down
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"babel-cli": "^6.14.0",
"babel-core": "^6.14.0",
"babel-eslint": "^7.1.0",
"babel-jest": "^16.0.0",
"babel-jest": "^17.0.0",
"babel-loader": "^6.2.5",
"babel-plugin-dev-expression": "^0.2.1",
"babel-plugin-lodash": "^3.2.9",
Expand All @@ -57,17 +57,17 @@
"babel-preset-es2015": "^6.14.0",
"babel-preset-react": "^6.11.1",
"babel-preset-stage-0": "^6.5.0",
"eslint": "^3.8.1",
"eslint": "^3.10.0",
"eslint-config-standard": "^6.1.0",
"eslint-config-standard-jsx": "^3.1.0",
"eslint-config-standard-react": "^4.1.0",
"eslint-plugin-promise": "^3.2.0",
"eslint-plugin-promise": "^3.3.2",
"eslint-plugin-react": "^6.3.0",
"eslint-plugin-standard": "^2.0.1",
"flow-bin": "^0.34.0",
"jest-cli": "^16.0.2",
"flow-bin": "^0.35.0",
"jest-cli": "^17.0.0",
"leaflet": "^1.0.0",
"lodash-webpack-plugin": "^0.10.1",
"lodash-webpack-plugin": "^0.10.5",
"react": "^15.3.2",
"react-addons-test-utils": "^15.3.2",
"react-dom": "^15.3.2",
Expand All @@ -77,6 +77,8 @@
},
"jest": {
"collectCoverage": true,
"scriptPreprocessor": "<rootDir>/node_modules/babel-jest"
"transform": {
".*": "<rootDir>/node_modules/babel-jest"
}
}
}
6 changes: 4 additions & 2 deletions src/MapLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export default class MapLayer extends MapComponent {
this.layerContainer.removeLayer(this.leafletElement)
}

render (): any {
return <div style={{display: 'none'}}>{this.props.children}</div>
render (): React.Element<*> | null {
return Array.isArray(this.props.children)
? <div style={{display: 'none'}}>{this.props.children}</div>
: (this.props.children || null)
}
}

0 comments on commit 956eca0

Please sign in to comment.