목차
접기
728x90
반응형
방법 1
import React, { Component } from 'react';
import { View, Text, StyleSheet, Button, Alert } from 'react-native';
let context: any;
class Test extends Component<any, any> {
constructor(props: any)
{
super(props);
context: this;
state:
{
text: 'test'
}
}
componentDidMount()
{
//setTimeout(() => { this.props.navigation.navigate('wallpaper') }, 3000 );
}
render()
{
return (
<View style={{ marginTop: 50 }}>
Hello World????????
<Button title="test Button" onPress={() => Alert.alert('hoho')} />
</View>
)
}
}
const styles = StyleSheet.create({
test:
{
color: 'red',
fontWeight: 'bold',
fontSize: 50
}
})
export default Test;
방법 2
import React, { Component } from 'react';
import { View, Text, StyleSheet, Button, Alert } from 'react-native';
let context: any;
class Test extends Component<any, any> {
constructor(props: any)
{
super(props);
context: this;
state:
{
text: 'test'
}
}
componentDidMount()
{
//setTimeout(() => { this.props.navigation.navigate('wallpaper') }, 3000 );
}
// 방법2
clicked()
{
this.props.navigation.navigate('wallpaper');
}
render()
{
return (
<View style={{ marginTop: 50 }}>
Hello World????????
<Button title="test Button" onPress={() => Alert.alert('hoho')} />
// 방법2
<Button title="TITLE" onPress={()=>this.clicked()} />
)
}
}
const styles = StyleSheet.create({
test:
{
color: 'red',
fontWeight: 'bold',
fontSize: 50
}
})
export default Test;
728x90
반응형
LIST
'IT 유용한 정보' 카테고리의 다른 글
[ react-native ] enum 설명 (0) | 2021.01.21 |
---|---|
[ react-native ] TextInput (0) | 2021.01.21 |
[ react-native ] state 정수 배열로 리스트 만들기, 정수 리스트 삭제하기. (0) | 2021.01.19 |
[ react-native ] prevState (0) | 2021.01.18 |
[ react-native ] Button 사용법 (0) | 2021.01.18 |