Skip to content

Instantly share code, notes, and snippets.

@cpjolicoeur
Created February 3, 2016 18:58
Show Gist options
  • Save cpjolicoeur/d497d5364bfc4ae6a872 to your computer and use it in GitHub Desktop.
Save cpjolicoeur/d497d5364bfc4ae6a872 to your computer and use it in GitHub Desktop.
2 files changed, 15 insertions(+), 7 deletions(-)
Components/.#SplashScreen.js | 1 -
components/price_list.js | 21 +++++++++++++++------
deleted Components/.#SplashScreen.js
@@ -1 +0,0 @@
-cpjolicoeur@Mandalore.70799
\ No newline at end of file
modified components/price_list.js
@@ -1,6 +1,7 @@
import React, {
Component,
ListView,
+ Text,
} from 'react-native';
import DrugPriceItem from './drug_price_item';
@@ -11,6 +12,7 @@ class PriceList extends Component {
let ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
this.state = {
dataSource: ds,
+ pricesLoaded: false,
};
}
@@ -26,18 +28,25 @@ class PriceList extends Component {
.then((responseData) => {
this.setState({
dataSource: this.state.dataSource.cloneWithRows(responseData),
+ pricesLoaded: true
});
})
.done();
}
render() {
- return (
- <ListView
- dataSource={this.state.dataSource}
- renderRow={this.renderDrugPrice}
- />
- );
+ if (this.state.pricesLoaded) {
+ return (
+ <ListView
+ dataSource={this.state.dataSource}
+ renderRow={this.renderDrugPrice}
+ />
+ );
+ } else {
+ return (
+ <Text>Loading prices</Text>
+ );
+ }
}
drugUrl() {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment