So i been thinking how to show default view if not yet pick dropdown value, so when user not yet choose the value you see the default value, i don't know if i am wrong using the null or !!selected but its still not showing the default screen
Snack Expo: https://snack.expo.dev/@mikess/react-native-select-dropdown
The Code:
App.js
import React, { FC, useState } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import Dropdown from './components/Dropdown';
const App: FC = () => {
const [selected, setSelected] = useState(undefined);
const data = [
{ label: 'One', value: '1' },
{ label: 'Two', value: '2' },
{ label: 'Three', value: '3' },
{ label: 'Four', value: '4' },
{ label: 'Five', value: '5' },
];
return (
<View style={styles.container}>
<Dropdown label="Select Item" data={data} onSelect={setSelected} />
{null && (
<View>
<Text> asdasdasda </Text>
</View>
) && selected.value == 1 ? (
<View>
<Text> Hallo </Text>
</View>
) : !!selected && selected.value == 2 ? (
<View>
<Text> Chiken </Text>
</View>
):null}
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
flexDirection: 'column',
},
});
export default App;
it's there another method if yes what method should i use, but if you can fix it thank you very much