i want to clear the all text input field on the button press instead it throws a an error saying undefined is not an option, as trying to take value={this.state.inputTextValue} from and clearing the input setState({inputTextValue : ''})
const[username, setUsername] = useState(""); const[mobile, setMobile] = useState(""); const[ isSubmit, setIsSubmit] = useState(false); useEffect(() => { const order = async () => { axios .post("*****************", JSON.stringify({ username:username, mobile: mobile, }) ) .then((response) => { console.log(response.data); setIsSubmit(false); }) .catch((err) => { console.log(err); }); }; if (isSubmit) order(); }, [isSubmit]); const orderHandler = (text) => { setUsername(text); };
HERE CLEARING THE TEXTINPUT VALUE ONPRESS
const handleSubmitEdit = () => { setState({inputTextValue : ''}) }; return (<ScrollView contentContainerStyle={{flexGrow: 1}} keyboardShouldPersistTaps='handled'><View style={styles.formwrap}><Form style={styles.mainform}><View style={styles.formgroup}> <SafeAreaView><View style={styles.formItems}>
HERE TAKING VALUE={value={this.state.inputTextValue}}
<TextInput placeholder="Full Name" onChangeText={orderHandler} value={this.state.inputTextValue} /></View><View style={styles.formItems}><TextInput placeholder="Mobile" style={styles.input} keyboardType={"phone-pad"} onChangeText={(text) => setMobile(text)} value={this.state.inputTextValue} /></View><View style={styles.buttonContainer}><TouchableOpacity style={styles.submit} onPress={() => {setIsSubmit(true),handleSubmitEdit()}}'><Text style={[styles.submitText]}>ORDER</Text></TouchableOpacity> </View></SafeAreaView> </View> </Form> </View> </ScrollView> )};