Put array values ​in `usecallback deps`

I have created a member registration function.

I want to pass the value of formState.values ​​from useCallback Hook to axios.post.

However, when I put formState.values in useCallback dependencies in the handleSubmit function, a ',' expected. type error occurs.

What should I do? You need to put the values array values ​​in formState as axios argument.

Can't you put formState.values in deps, axios argument values like this?

How do I pass the value value as an argument?

const [formState, setFormState] = useState<formState>({
    isValid: false,
    values: {},
    touched: {},
    errors: {},

const handleSubmit = useCallback((event: FormEvent) => {
            withCredentials: true,
    .then(response => {
        const { accessToken } = response.data; 
        axios.defaults.headers.common['Authorization'] = `Bearer ${accessToken}`;
    .catch(error => {

}, [formState.values])

1 answer

  • answered 2021-11-29 08:19 TheWuif

    would say the problem is in the post call:

      formState.values, // or {values: formState.values}
      { withCredentials: true },

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum