API response
{
"result": [
{
"id": "postcode-0001",
"text": "0200"
},
{
"id": "postcode-00010",
"text": "2607"
},
]}
I am using this dependency: react-native-multiple-select
I want to add the API data to be included in the multi picker and this is my code
const [postcode, setPostcodes] = useState([]);
const responsepostal = await axios.post
(`${urldemo}postal-codes`)
setDataPostal(responsepostal.data.result)
This my return code for styling
Issue: the API postcode data in the multi-picker does not show. I don't want more than three postcode data in the multi-picker
<MultiSelect
style={GlobalSS.picker}
selectedValue={postcode}
onValueChange={(itemValue, itemIndex) => setPostcodes(itemValue)}
// items={postcode}
selectedItems={postcode}
// onSelectedItemsChange={postcode}
selectText="Select Postcode"
searchInputPlaceholderText="Search Post Code"
altFontFamily="ProximaNova-Light"
tagRemoveIconColor="#CCC"
tagBorderColor="#CCC"
tagTextColor="#CCC"
selectedItemTextColor="#CCC"
selectedItemIconColor="#CCC"
itemTextColor="#000"
displayKey="name"
searchInputStyle={{ color: "#CCC" }}
submitButtonColor="#CCC"
submitButtonText="Submit"
>
{/* <Picker.Item color='grey'
label=
"Select Postcode"
// {postcode}
value=
""
// {postcode}
/> */}
{datapostal.map((item) => (
<Picker.Item label={item.text} value={item.id} />
))}
</MultiSelect>;
use items props
<MultiSelect
style={GlobalSS.picker}
selectedValue={postcode}
items={postcode}
onValueChange={(itemValue, itemIndex) => setPostcodes(itemValue)}
// items={postcode}
selectedItems={postcode}
// onSelectedItemsChange={postcode}
selectText="Select Postcode"
searchInputPlaceholderText="Search Post Code"
altFontFamily="ProximaNova-Light"
tagRemoveIconColor="#CCC"
tagBorderColor="#CCC"
tagTextColor="#CCC"
selectedItemTextColor="#CCC"
selectedItemIconColor="#CCC"
itemTextColor="#000"
displayKey="name"
searchInputStyle={{ color: "#CCC" }}
submitButtonColor="#CCC"
submitButtonText="Submit"
/>