fix: update form state on getting existing mod data
All checks were successful
Release to Staging / build_and_release (push) Successful in 46s
All checks were successful
Release to Staging / build_and_release (push) Successful in 46s
This commit is contained in:
parent
35c1d704e0
commit
3b2e899c14
@ -60,7 +60,7 @@ export const ModForm = ({ existingModData }: ModFormProps) => {
|
|||||||
const [isPublishing, setIsPublishing] = useState(false)
|
const [isPublishing, setIsPublishing] = useState(false)
|
||||||
const [gameOptions, setGameOptions] = useState<GameOption[]>([])
|
const [gameOptions, setGameOptions] = useState<GameOption[]>([])
|
||||||
const [formState, setFormState] = useState<ModFormState>(
|
const [formState, setFormState] = useState<ModFormState>(
|
||||||
initializeFormState(existingModData)
|
initializeFormState()
|
||||||
)
|
)
|
||||||
const [formErrors, setFormErrors] = useState<FormErrors>({})
|
const [formErrors, setFormErrors] = useState<FormErrors>({})
|
||||||
|
|
||||||
@ -70,6 +70,12 @@ export const ModForm = ({ existingModData }: ModFormProps) => {
|
|||||||
}
|
}
|
||||||
}, [location.pathname]) // Only trigger when the pathname changes to submit-mod
|
}, [location.pathname]) // Only trigger when the pathname changes to submit-mod
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (existingModData) {
|
||||||
|
setFormState(initializeFormState(existingModData))
|
||||||
|
}
|
||||||
|
}, [existingModData])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const options = games.map((game) => ({
|
const options = games.map((game) => ({
|
||||||
label: game['Game Name'],
|
label: game['Game Name'],
|
||||||
|
Loading…
Reference in New Issue
Block a user