diff --git a/src/components/ComplexListView.js b/src/components/ComplexListView.js index 3953ad7..2b1c6a0 100644 --- a/src/components/ComplexListView.js +++ b/src/components/ComplexListView.js @@ -24,6 +24,15 @@ export default class MeteorListView extends Component { }) }; } + componentWillReceiveProps(props) { + const { elements } = props; + + const elems = elements(); + this.setState({ + ds: this.state.ds.cloneWithRows(elems) + }); + + } componentWillMount() { const { elements } = this.props; diff --git a/src/components/ListView.js b/src/components/ListView.js index e0c7734..6cef67f 100644 --- a/src/components/ListView.js +++ b/src/components/ListView.js @@ -29,9 +29,22 @@ export default class MeteorListView extends Component { }) }; } + componentWillReceiveProps(props) { + const { collection, selector, options } = props; + + this.update(Data.db[collection].find(selector, options)); + } componentWillMount() { const { collection, selector, options } = this.props; + + this.update = results=>{ + this.setState({ + ds: this.state.ds.cloneWithRows(results) + }); + }; + + if(!Data.db[collection]) { Data.db.addCollection(collection) } @@ -40,11 +53,7 @@ export default class MeteorListView extends Component { return Data.db[collection].find(selector, options); }); - this.items.subscribe(results=>{ - this.setState({ - ds: this.state.ds.cloneWithRows(results) - }); - }); + this.items.subscribe(this.update); } componentWillUnmount() { this.items.dispose();