twobin / twobin/react-lazyload
Decorator broken
- 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{
```

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.