Skip to content

Commit

Permalink
Fixed global require eslint issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlplusb committed May 21, 2016
1 parent d09bf5e commit 542959d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
6 changes: 1 addition & 5 deletions src/SizeMe.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ import React, { Children, Component, PropTypes } from 'react';
import ReactDOM from 'react-dom';
import invariant from 'invariant';
import { throttle } from 'lodash';

// Lazily require to not cause bug
// https://github.com/ctrlplusb/react-sizeme/issues/6
// import resizeDetector from './resizeDetector';
const resizeDetector = () => require(`./resizeDetector`).default;
import resizeDetector from './resizeDetector';

const defaultConfig = {
monitorWidth: true,
Expand Down
17 changes: 14 additions & 3 deletions src/resizeDetector.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
import createResizeDetector from 'element-resize-detector';

const resizeDetector = createResizeDetector({
strategy: `scroll`
});
let instance;

// Lazily require to not cause bug
// https://github.com/ctrlplusb/react-sizeme/issues/6
// import resizeDetector from './resizeDetector';
function resizeDetector() {
if (!instance) {
instance = createResizeDetector({
strategy: `scroll`
});
}

return instance;
}

export default resizeDetector;

0 comments on commit 542959d

Please sign in to comment.