Skip to content

Instantly share code, notes, and snippets.

@jgeraerts
Created December 15, 2018 18:27
Show Gist options
  • Save jgeraerts/045d7a9bc5d250fcb8952fdce2aafa2b to your computer and use it in GitHub Desktop.
Save jgeraerts/045d7a9bc5d250fcb8952fdce2aafa2b to your computer and use it in GitHub Desktop.
import React from 'react';
import {
StyleSheet,
Text,
View,
Button,
} from 'react-native';
class Ready extends React.Component {
render() {
return (
<Text>Ik ben ready</Text>
)
}
}
class NotReady extends React.Component {
render() {
return (
<View>
<Text>ik ben niet ready. Druk op de knop</Text>
<Button title="klaar" onPress={this.props.klikfunctie} />
</View>
)
}
}
export default class App extends React.Component {
constructor(props) {
super(props)
this.state={
ready: false,
};
this.opDeKnopGeduwd = this.opDeKnopGeduwd.bind(this);
};
opDeKnopGeduwd() {
this.setState({ready: true});
}
render() {
let component = this.state.ready ?
<Ready/> :
<NotReady klikfunctie={this.opDeKnopGeduwd} />;
return (
<View style={styles.container}>
{component}
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment