Skip to content

Instantly share code, notes, and snippets.

@simontreny
Last active March 11, 2019 10:24
Show Gist options
  • Save simontreny/c882d26e0ba13f9b11a73356ecaecc53 to your computer and use it in GitHub Desktop.
Save simontreny/c882d26e0ba13f9b11a73356ecaecc53 to your computer and use it in GitHub Desktop.
Ecran simple avec un entête et un contenu texte
import React from "react";
import { Image, ScrollView, Text, View } from "react-native";
export default class App extends React.Component {
state = { text: "" };
render() {
return (
<ScrollView style={{ flex: 1, backgroundColor: "white" }}>
{this.renderHeader()}
{this.renderContent()}
</ScrollView>
);
}
renderHeader() {
const headerHeight = 240;
return (
<View style={{ height: headerHeight }}>
<Image
style={{ width: "100%", height: "100%" }}
source={require("./cover.jpg")}
/>
</View>
);
}
renderContent() {
return (
<View style={{ padding: 20 }}>
<Text style={{ fontSize: 24, fontWeight: "800", marginBottom: 16 }}>
BORDEAUX
</Text>
<Text>{this.state.text}</Text>
</View>
);
}
async componentDidMount() {
const res = await fetch("https://loripsum.net/api/plaintext");
this.setState({ text: await res.text() });
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment