twobin / twobin/react-lazyload

Decorator broken

Open
#166 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
5.9k
Forks
485
PR merge metrics
No merged PRs in 30d

Description

When using the built in decorator with class syntax the error 'cannot call class as function' is thrown by react. This is related to the extra parameters of the decorator. Changing the decorator to pass the parameters into another function that then applies the HOC logic fixes this:

**FIX**:
```
const Lazy = (height, offset) => (Comp) => {
return class Lazy extends React.Component {
constructor() {
super();
}

render() {
let {...other} = this.props;

return


}
}
}
export default Lazy;
```

I.E. notice: (height, offset) => (Comp) =>

**Offending Code:**
```
@LazyLoad({height: 50,offset: 100})
class ExampleClass extends React.Component{
```
![proof](https://i.imgur.com/EYaiPrm.png)

i'll submit a PR if you will merge

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.