toystars / react-native-multiple-select

Simple multi-select component for react-native
MIT License
565 stars 314 forks source link

getSelectedItemsExt not working functional component #173

Closed YunusEmreNalbant closed 3 years ago

YunusEmreNalbant commented 3 years ago

Hi,

getSelectedItemsExt not working. does not show any thing. I used a functional component

`

<MultiSelect
                ref={multiSelect}
                styleListContainer={{ height: "auto" }}
                items={acceptedLocations}
                fixedHeight={true}
                uniqueKey="id"
                fontSize={16}
                textColor={COLORS.gray2}
                iconSearch={true}
                onSelectedItemsChange={onSelectedItemsChangeLocations}
                selectedItems={acceptedLocation}
                selectText="Seçiniz"
                searchInputPlaceholderText="Arama yap..."
                onChangeInput={(text) => console.log(text)}
                altFontFamily="ProximaNova-Light"
                tagRemoveIconColor="red"
                tagBorderColor="#CCC"
                tagTextColor="#CCC"
                selectedItemTextColor="green"
                selectedItemIconColor="green"
                itemTextColor="#000"
                displayKey="name"
                searchInputStyle={{ color: "#CCC" }}
                submitButtonColor="#CCC"
                submitButtonText="Seçilenleri Onayla"
              />
              {multiSelect?.current?.getSelectedItemsExt(acceptedLocation)}

`

react-native: 0.63.4 react-native-multiple-select: 0.5.6

human2012 commented 3 years ago

@YunusEmreNalbant Hi) Is the question resolved? It doesn't work for me either.

YunusEmreNalbant commented 3 years ago

@YunusEmreNalbant Hi) Is the question resolved? It doesn't work for me either.

Hi, no. I tried to reach the solution with another way

sam9010 commented 2 years ago

@YunusEmreNalbant @human2012 I fix it, my sample code is:

export const Mdl_BudgetCode = (props) => {
  const multiSelect = useRef();

<MultiSelect
.....
    ref={component => {
                multiSelect.current = component;
                if (multiSelect.current) {
                    multiSelect.current._toggleSelector() ;
                    multiSelect.current._submitSelection = () => {
                    console.log('Getting here.. you can add your stuff');
                    multiSelect.current._toggleSelector();
                    multiSelect.current._clearSearchTerm();
                  };
                }
              }}
.....
 />

 <ScrollView>
              {multiSelect.current && multiSelect.current.getSelectedItemsExt(props.arrOfBudgetCodeId)}
 </ScrollView>
}