[[oktatas:telefon:react_native:nezetek_kapcsolasa|< Nézetek kapcsolása]]
====== Nézetek kapcsolása osztályból ======
* **Szerző:** Sallai András
* Copyright (c) Sallai András, 2021, 2022
* Licenc: [[https://creativecommons.org/licenses/by-sa/4.0/|CC Attribution-Share Alike 4.0 International]]
* Web: https://szit.hu
===== Osztállyal =====
==== App.js ====
import React, { Component} from 'react';
import { View, StyleSheet, Button, Text } from 'react-native';
import ComponentA from './components/componenta';
import ComponentB from './components/componentb';
import ComponentC from './components/componentc';
export default class App extends Component {
state = {
selectedTab: ''
}
setTab = (tab) => {
this.setState({selectedTab: tab});
}
selectTab = () => {
switch(this.state.selectedTab) {
case 'A':
return
case 'B':
return
case 'C':
return
default:
return
}
}
render() {
return (
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'skyblue',
alignItems: 'center',
justifyContent: 'center',
},
buttonBox: {
flex: 1,
width: '100%',
},
component: {
flex: 1,
}
});
==== Komponensek ====
import React, { Component} from 'react';
import { View, StyleSheet, Text } from 'react-native';
export default class ComponentA extends Component {
render() {
return (
A komponens
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
import React, { Component} from 'react';
import { View, StyleSheet, Text } from 'react-native';
export default class ComponentB extends Component {
render() {
return (
B komponens
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
import React, { Component} from 'react';
import { View, StyleSheet, Text } from 'react-native';
export default class ComponentC extends Component {
render() {
return (
C komponens
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});