Skip to content
This repository was archived by the owner on Nov 11, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 36 additions & 4 deletions lib/LazyloadListView.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,46 @@ import {

import LazyloadScrollView from './LazyloadScrollView';

class LazyloadListView extends Component{
class LazyloadListView extends Component {
static displayName = 'LazyloadListView';

constructor(props, context) {
super(props, context);

this._setScrollViewRef = this._setScrollViewRef.bind(this);
}

get scrollProperties() {
const { _scrollView } = this;
if (!_scrollView) { return; }
return _scrollView.scrollProperties;
}

get scrollTo() {
const { _scrollView } = this;
if (!_scrollView) { return; }
return _scrollView.scrollTo;
}

_setScrollViewRef(ref) {
this._scrollView = ref;
}

_additionalListViewProps() {
if (!this.props.name) {
return {};
}
return {
renderScrollComponent: props => <LazyloadScrollView {...props} />
};
}

render() {
return this.props.name ? <ListView
return <ListView
{...this.props}
renderScrollComponent={props => <LazyloadScrollView {...props} />}
/> : <ListView {...this.props} />;
{...this._additionalListViewProps()}
ref={this._setScrollViewRef}
/>;
}
}

Expand Down
4 changes: 3 additions & 1 deletion lib/LazyloadView.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ class LazyloadView extends Component{
};

measureLayout = (...args) => {
this._root.measureLayout(...args);
if (this._root) {
this._root.measureLayout(...args);
}
};

setNativeProps = (...args) => {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "react-native-lazyload",
"version": "1.0.4",
"description": "lazyload for react native",
"version": "1.0.2",
"license": "MIT",
"main": "./index.js",
"repository": {
Expand Down