[[oktatas:telefon:react_native|< React Native]]
====== Osztályhasználat ======
* **Szerző:** Sallai András
* Copyright (c) Sallai András, 2021
* Licenc: [[https://creativecommons.org/licenses/by-sa/4.0/|CC Attribution-Share Alike 4.0 International]]
* Web: https://szit.hu
===== Szöveg =====
A React Native kezdésben már volt példa az osztályhasználatra. Legyen itt újra:
import React, { Component} from 'react';
import { View, StyleSheet, Text } from 'react-native';
export default class App extends Component {
render() {
return (
Helló Világ
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
===== TextInput =====
import React, { Component} from 'react';
import { View, StyleSheet, Text, TextInput } from 'react-native';
export default class App extends Component {
state={
name: '',
}
handleText = text => {
this.setState({name: text});
}
render() {
return (
Helló Világ
this.handleText(text)}
/>
{this.state.name}
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
input: {
borderColor: 'green',
borderWidth: 3,
width: '90%',
fontSize: 35,
}
});