Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

picker created dynamically?

$
0
0

I am new to React Native and to TypeScript. I was wondering if it is possible to create a picker completely dynamically. For instance, instead of using (const [selectedQLType, setQLTypePicker] = useState('');) is it possible to dynamically create those state variable so that you can then generate severals pickers using a map function for instance based on an array of parameters ?

import {Picker} from '@react-native-picker/picker';

...const [selectedQLType, setQLTypePicker] = useState('');

  return (<View>    <Picker        selectedValue={selectedQLType}        onValueChange={(itemValue, itemIndex) => setQLTypePicker(itemValue)}>        {variableType.map(itemIdx => <Picker.Item             label={itemIdx}             key={itemIdx}             value={itemIdx}           />)} </Picker>

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>