picker
picker copied to clipboard
Cannot trigger focus using ref
dropdownRef: React.RefObject<Picker<string>>;
textBoxRef: React.RefObject<TextInput>;
constructor(props: any) {
super(props);
this.dropdownRef = React.createRef();
this.textBoxRef = React.createRef();
}
async componentDidMount() {
setTimeout(() => {
this.dropdownRef.current?.focus();
setTimeout(() => {
this.textBoxRef.current?.focus();
}, 3000);
}, 3000);
}
render() {
return <View>
<View >
<View >
<Picker
ref={this.dropdownRef}
>
<Picker.Item label={"Apples"} value={1} key={1} />
<Picker.Item label={"Oranges"} value={2} key={2} />
</Picker>
</View>
<View>
<TextInput
ref={this.textBoxRef}
/>
</View>
</View>
</View>
}
Focus does not land on picker when its ref gets called in componentDidMount. Is there a fix for this?
Using:
- react-native-picker/picker: 2.4.1
- react-native: 0.67.4
- react-native-windows: 0.67.8
- Platform: Windows 10/11
Its currently only available for Android ... no idea why. This definitely needs to be fixed though.