Skip to content

Commit

Permalink
Replace console statements with documentation (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelgautier authored and jasonslyvia committed Mar 12, 2018
1 parent 8c3a8ec commit 3dc5c99
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 24 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ So you can safely send request in your component's `componentDidMount` without w

## Props

### children

Type: Node Default: undefined

**NOTICE**
Only one child is allowed to be passed.

### height

Type: Number/String Default: undefined
Expand Down Expand Up @@ -157,6 +164,11 @@ If you provide a number, that will be how many `ms` to wait; if you provide `tru

[demo](https://jasonslyvia.github.io/react-lazyload/examples/#/debounce)

### wheel

**DEPRECATED NOTICE**
This props is not supported anymore, try set `overflow` for lazy loading in overflow containers.

## Utility

### forceCheck
Expand All @@ -175,7 +187,6 @@ Then call the function:
forceCheck();
```


## Scripts

```
Expand Down
25 changes: 2 additions & 23 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,31 +177,10 @@ class LazyLoad extends Component {
}

componentDidMount() {
if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production') {
if (React.Children.count(this.props.children) > 1) {
console.warn('[react-lazyload] Only one child is allowed to be passed to `LazyLoad`.');
}

if (this.props.wheel) { // eslint-disable-line
console.warn('[react-lazyload] Props `wheel` is not supported anymore, try set `overflow` for lazy loading in overflow containers.');
}

// Warn the user if placeholder and height is not specified and the rendered height is 0
if (!this.props.placeholder && this.props.height === undefined && ReactDom.findDOMNode(this).offsetHeight === 0) {
console.warn('[react-lazyload] Please add `height` props to <LazyLoad> for better performance.');
}
}

// It's unlikely to change delay type on the fly, this is mainly
// designed for tests
let needResetFinalLazyLoadHandler = false;
if (this.props.debounce !== undefined && delayType === 'throttle') {
console.warn('[react-lazyload] Previous delay function is `throttle`, now switching to `debounce`, try setting them unanimously');
needResetFinalLazyLoadHandler = true;
} else if (delayType === 'debounce' && this.props.debounce === undefined) {
console.warn('[react-lazyload] Previous delay function is `debounce`, now switching to `throttle`, try setting them unanimously');
needResetFinalLazyLoadHandler = true;
}
const needResetFinalLazyLoadHandler = (this.props.debounce !== undefined && delayType === 'throttle')
|| (delayType === 'debounce' && this.props.debounce === undefined);

if (needResetFinalLazyLoadHandler) {
off(window, 'scroll', finalLazyLoadHandler, passiveEvent);
Expand Down

0 comments on commit 3dc5c99

Please sign in to comment.