Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

value is: Function anonymous #693

Closed
Acidias opened this issue Aug 23, 2023 · 2 comments
Closed

value is: Function anonymous #693

Acidias opened this issue Aug 23, 2023 · 2 comments

Comments

@Acidias
Copy link

Acidias commented Aug 23, 2023

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?

@px-amaac
Copy link

const value = valueFunction() === your value. 🤷

@Acidias Acidias closed this as completed Aug 24, 2023
@Acidias
Copy link
Author

Acidias commented Aug 24, 2023

Thank you! :) I'm new yet

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

No branches or pull requests

2 participants