Randy_Johnson's avatar

InertiaJS ReactJS Clearing Inputs

In the data, I have data, and this data has as shown in useForm, but am a little confused if this is connected to the actual input field. If I console.log(event.target.name + ' ' + event.target.type + ' ' + event.target.value) the .name is as shown in the useForm data, parent, name as so on. I am wondering, can I use this to clear the data inside the input fields, or is there no relation.

const { data, setData, post, processing } = useForm({
        parent: '',
        name: '',
        dob: '',
        language: '',
    });

    const onHandleChange = (event) => {
        setData(event.target.name, event.target.type === 'checkbox' ? event.target.checked : event.target.value);
    };

    const submit = (e) => {
        e.preventDefault(); 

        Inertia.post('dashboard/student', data, {
            preserveScroll: true,
        })
    };
0 likes
1 reply

Please or to participate in this conversation.