Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

react native android DropdownList onChange not working #16

Open
leegilhak opened this issue May 28, 2021 · 1 comment
Open

react native android DropdownList onChange not working #16

leegilhak opened this issue May 28, 2021 · 1 comment

Comments

@leegilhak
Copy link

leegilhak commented May 28, 2021

My Code

<View>
          <DropdownList
            title="반려동물"
            items={items}
            defaultValue={'반려동물을 선택해주세요.'}
            onChange={(item: string) => {
              const targetItem = items.find(petItem => petItem.value === item);

              dispatch({type: 'ANIMALINSERT', animal_type: item});
              dispatch({
                type: 'ANIMALIDINSERT',
                animal_type_id: targetItem.key,
              });
            }}
            customStyleCancelText={{
              cancelTextLight: {
                fontSize: 15,
                fontWeight: '500',
                color: '#FF5924',
              },
              cancelTextDark: {
                fontSize: 15,
                fontWeight: '500',
                color: '#FF5924',
              },
            }}
          />
        </View>

onChange android not working

else if (react_native_1.Platform.OS === 'android') {
           
            return (jsx_runtime_1.jsxs(react_native_1.View, Object.assign({ style: renderContainerStyle() }, { children: [jsx_runtime_1.jsx(react_native_1.View, Object.assign({ style: styles.labelContainer }, { children: jsx_runtime_1.jsx(react_native_1.Text, Object.assign({ style: renderLabelTextStyle() }, { children: props.title }), void 0) }), void 0),
                    jsx_runtime_1.jsx(picker_1.Picker, Object.assign({ mode: "dropdown", selectedValue: value, style: { height: 60, width: width - 16 },

 onValueChange: (value) => setValue(value) },

 { children: props.items.map((item, i) => {
                            return (jsx_runtime_1.jsx(picker_1.Picker.Item, { label: item.label, value: item.value, color: renderPickerItemStyle() }, i));
                        }) }), void 0)] }), void 0));
        }

In the above code, 'setValue' is 'OnValueChange: (Value) => setValue(Value)}', so onChange does not work in the props.
It should be modified to 'selectValue'.

@dchdimitrov
Copy link

+1

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants