usecallback Expected 2 arguments, but got 1

The solution for “usecallback Expected 2 arguments, but got 1” can be found here. The following code will assist you in solving the problem.

// file: useForm

import { useState, useCallback } from ‘react’;

export const useForm = (initialState: T) => {
const [values, setValues] = useState(initialState);

return [
values,
useCallback((event: { target: { name: string; value: unknown; }; }) => {
setValues(v => ({ …v, [event.target.name]: event.target.value });
}, []) // you may do not have this `[]` check this out
]
};

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

0
inline scripts encapsulated in