[[oktatas:telefon:react_native:nezetek_kapcsolasa|< Nézetek kapcsolása]]
====== Nézetek kapcsolása függvénybő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
===== Könyvtárszerkezet =====
app01/
|-assets/
|-components/
| |-compa.js
| |-compb.js
| `-compc.js
|-App.js
|-app.json
|-babel.config.js
|-package.json
`-yarn.lock
===== Függvényekkel =====
import { StyleSheet, Text, View, Button } from 'react-native';
import { useState } from 'react';
import Compa from './components/compa';
import Compb from './components/compb';
import Compc from './components/compc';
export default function App() {
const [selectedTab, setSelectedTab] = useState();
let setTab = (tab) => {
setSelectedTab(tab);
}
let selectTab = () => {
switch(selectedTab) {
case 'A':
return
case 'B':
return
case 'C':
return
default:
return
}
}
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 from 'react';
import { View, StyleSheet, Text } from 'react-native';
export default function Compa() {
return (
A komponens
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
import React from 'react';
import { View, StyleSheet, Text } from 'react-native';
export default function Compb() {
return (
B komponens
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
import React from 'react';
import { View, StyleSheet, Text } from 'react-native';
export default function Compc() {
return (
C komponens
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});