Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react-native-dropdown-picker

#go to the wesite and read the docs
Web_link: https://hossein-zare.github.io/react-native-dropdown-picker-website/docs/
    
#sample: 
#installation
npm install react-native-dropdown-picker

const [facultyOpen, setFacultyOpen] = useState(false);
const [facultyValue, setFacultyValue] = useState('electrical');
const [faculty, setFaculty] = useState([
    { label: 'Electrical & Computer Engineering', value: 'electrical' },
    { label: 'Civil Engineering', value: 'civil' },
    { label: 'Mechanical Engineering', value: 'mechanical' },
]);
#after-return
#used tailwind for style. delete all tw`` part if you don't use tailwind css
<View style={[tw`mb-3 z-50`]}>
          <Text
            style={[
              tw`font-semibold text-purple-600 ml-1 mb-1`,
              { fontSize: 18 },
            ]}
          >
            Faculty
          </Text>
          <DropDownPicker
            open={facultyOpen}
            value={facultyValue}
            items={faculty}
            setValue={setFacultyValue}
            setItems={setFaculty}
            setOpen={setFacultyOpen}
            style={[tw`bg-gray-200 w-full px-4 py-3 border-0`]}
            containerStyle={[tw`border-0 bg-gray-200 rounded-lg`]}
            dropDownContainerStyle={[
              tw``,
              {
                backgroundColor: '#E5E7EB',
                borderRadius: 10,
                zIndex: 1,
                borderWidth: 0,
              },
            ]}
          />
        </View>
Comment

react-native-dropdown-picker for form react native

import React, { useState } from 'react';
import SelectPicker from 'react-native-form-select-picker'; // Import the package
//...
const options = ["Apple", "Banana", "Orange"];
const YourComponent = ({ /* your props */ }) => {
	const [selected, setSelected] = useState();
	return (
		//...

		<SelectPicker
			onValueChange={(value) => {
				// Do anything you want with the value. 
				// For example, save in state.
				setSelected(value);
			}}
			selected={selected}
			>
			
			{Object.values(options).map((val, index) => (
				<SelectPicker.Item label={val} value={val} key={index} />
			))}

		</SelectPicker>

		//...
	)
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to fetch data from json file in flutter 
Javascript :: delete value from json array with index 
Javascript :: ajax post csrf codeigniter 
Javascript :: active class always appear in navlink 
Javascript :: change dictionary value in React js 
Javascript :: change node bash root 
Javascript :: google scripts string split 
Javascript :: python dictionary setdefault in javascript 
Javascript :: addeventlistener javascript multiple functions 
Javascript :: foreach and replace item based on condition 
Javascript :: objeto con método javascript 
Javascript :: hide an element when window resize css 
Javascript :: dotenv in node js 
Javascript :: react node-sass 
Javascript :: how to send dm to every member in discord with discord.js 
Javascript :: form submit jquery 
Javascript :: create angular app with routing 
Javascript :: import downloadcsv from "vue-json-csv"; 
Javascript :: req.body is empty express js 
Javascript :: object.create() js 
Javascript :: blob to pdf javascript 
Javascript :: how to access items inside anonymous object 
Javascript :: how to check if a letter is capital in javascript 
Javascript :: node api return file 
Javascript :: how to create a react app 
Javascript :: socket io add timeout 
Javascript :: discord.js reading json object from json 
Javascript :: what is tostring in js 
Javascript :: //Splice remove and add new elements in an array in javascript 
Javascript :: en eternal gloden braid 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =