Searchable drop down value not getting updated in inputbox in react-native 3.0

Viewed 1089

I am trying to implement the searchable drop down component and able to implemented successfully. But getting one issue, while selected a value from list its not getting updated in input box.

I am following the below component and implemented same code.

https://www.npmjs.com/package/react-native-searchable-dropdown

If anyone have idea. Please help me. Thanks in advance!

1 Answers

You need to use selectedItems props with your SearchableDropdown Component.

  const [utilizedDivName, setUtilizedDivName] = useState('');
  const [utilizedList, srtUtilizedList] = useState([]);
  
 <SearchableDropdown
          onItemSelect={(item) => { setUtilizedDivName(item) }}
          selectedItems={utilizedDivName}
          containerStyle={{ padding: 5 }}
          itemStyle={{
              padding: 10,
              marginTop: 2,
              backgroundColor: '#ddd',
              borderColor: '#bbb',
              borderWidth: 1,
              borderRadius: 5,
            }}
            itemTextStyle={{ color: '#222' }}
            itemsContainerStyle={{ maxHeight: 140 }}
            items={utilizedList}
            resetValue={false}
            textInputProps={
              {
                placeholder: "Please Choose Utilized Division",
                underlineColorAndroid: "transparent",
                style: {
                    padding: 12,
                    borderWidth: 1,
                    borderColor: '#ccc',
                    borderRadius: 5,
                },
                // onTextChange: text => alert(text)
              }
            }
            listProps={
              {
                nestedScrollEnabled: true,
              }
            }
        />

Related