Skip to content

Commit

Permalink
Merge branch 'main' into feature/#72
Browse files Browse the repository at this point in the history
  • Loading branch information
Yumax-panda committed Apr 8, 2024
2 parents 05348dd + 5435a24 commit 153b6ac
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useEffect, useState } from 'react'

import { zodResolver } from '@hookform/resolvers/zod'
import { useRouter } from 'next/navigation'
import { useForm } from 'react-hook-form'
import { toast } from 'react-toastify'

Expand Down Expand Up @@ -36,6 +37,7 @@ export const useEdit = ({
_initialThumbnail,
)
const [isLoading, setIsLoading] = useState(false)
const router = useRouter()

const { control, handleSubmit, formState, watch, setValue } =
useForm<FormValues>({
Expand Down Expand Up @@ -130,6 +132,10 @@ export const useEdit = ({
const { error } = await res.json()
throw new Error(error)
}

// これがないと編集した内容が反映されない
// ref: https://nextjs.org/docs/app/building-your-application/caching#routerrefresh
return router.refresh()
}

const getErrorMessage = (e: FieldErrors<FormValues>) => {
Expand Down

0 comments on commit 153b6ac

Please sign in to comment.