I created a functional component and I'm trying to reset or unselect a select picker by clicking on a button, I tried to use forceUpdate() but it didn't work.
I'm using a library called react-native-picker-select
My code:
import React, {useState} from 'react';
import { Text, View, StyleSheet, TouchableOpacity} from 'react-native';
import RNPickerSelect from 'react-native-picker-select';
export default function App() {
const clean = () => {
//reset picker
}
return (
<View>
<RNPickerSelect
onValueChange={(value) => console.log("value")}
placeholder={{
label: 'Select'
}}
useNativeAndroidPickerStyle={false}
items={[
{ label: 'Option 1', value: '1' },
{ label: 'Option 2', value: '2' },
{ label: 'Option 3', value: '3' },
]}
/>
<TouchableOpacity
onPress={clean}>
<Text>Clean</Text>
</TouchableOpacity>
</View>
);
}
Code running: