getting Empty data from ‘react-hook-form’ of handleSubmit() method

  javascript, react-hooks, react-native, reactjs

//I am working in react-native and used ‘react-hook-forms’ for dynamic form creation,
but Form is returning empty data object, but it should return values typed in form. onSubmit function should console.log values given in form, but I don’t know why it does not working. Please check it out.

<View>
    <Controller
        control={control}
        name={"first"}
        rules={{ required: true }}
        render={({ field: { onChange, value } }) => (
            <TextInput
                onChangeText={e => { onChange(e); onChangeFirst(e); }}
                value={value}
            />
        )} />


    <TouchableOpacity onPress={handleSubmit((data) => { console.log("DATA::",data) })}>
        <Text}]}>ADD</Text>
    </TouchableOpacity>
</View>

Source: Ask Javascript Questions

LEAVE A COMMENT