Closed Acidias closed 10 months ago
I'm trying to use with formik but I'm keep getting "Value: [Function anonymous]"
const [open, setOpen] = useState(false); const [value, setValue] = useState(null); const [items, setItems] = useState([ { label: "Tier 1", value: "Tier 1" }, { label: "Tier 2", value: "Tier 2" }, ]); const onOpen = useCallback(() => { console.log("Open"); }); const initialValues = { buildingTo: selectedBuildingTo, tier: "", }; const handleFormSubmit = (values) => { console.log("values ", values); const allValues = { contract: selectedContract, building: selectedBuilding, buildingTo: selectedBuildingTo, tier: values.tier, }; console.log("All Form Values:", allValues); setIsLoading(true); // Show spinner }
<Formik initialValues={initialValues} validationSchema={validationSchema} onSubmit={handleFormSubmit} > {({ handleChange, handleBlur, handleSubmit, setFieldValue, values, errors, }) => { const onSubmit = () => { console.log("Submit button pressed. Form values:", values); handleFormSubmit(values); }; return ( <> <Modal transparent={true} animationType="slide" visible={isLoading} onRequestClose={() => {}} > <View style={styles.overlay}> <ActivityIndicator size="large" color="#4A7CFF" /> </View> </Modal> <View style={{ zIndex: 1, padding: 0 }}> <ContractBuildingSelector2 onContractSelect={setSelectedContract} onBuildingSelect={setSelectedBuilding} onBuildingSelectTo={setSelectedBuildingTo} /> </View> <DropDownPicker open={open} onOpen={onOpen} value={value} items={items} setOpen={setOpen} setValue={(value) => { setValue(value); console.log("Value:", value); setFieldValue("tier", value); }} setItems={setItems} /> <View style={styles.section}> <TouchableOpacity style={styles.button} onPress={onSubmit} disabled={isLoading} // Disable button while submitting > <Text style={styles.buttonText}>Submit</Text> </TouchableOpacity> </View> </> ); }} </Formik>
I tried lot of things, and the same setValue methode I use in a different form and there is working fine... Any ide what is the problem?
const value = valueFunction() === your value. 🤷
const value = valueFunction()
Thank you! :) I'm new yet
I'm trying to use with formik but I'm keep getting "Value: [Function anonymous]"
I tried lot of things, and the same setValue methode I use in a different form and there is working fine... Any ide what is the problem?