Fix job dropdown not showing jobs
This was happening due to a combination of the useEffect not being updated properly in the New route and the state being completely reset when cleaned in the new route, including values that should persist.
This commit is contained in:
parent
25362d81df
commit
b3ec6a5d08
2 changed files with 9 additions and 5 deletions
|
|
@ -10,7 +10,6 @@ import SearchModal from '~components/SearchModal'
|
|||
|
||||
import api from '~utils/api'
|
||||
import { appState } from '~utils/appState'
|
||||
import { ACCESSORY_JOB_IDS } from '~utils/jobsWithAccessories'
|
||||
import type { JobSkillObject, SearchableObject } from '~types'
|
||||
|
||||
import './index.scss'
|
||||
|
|
|
|||
|
|
@ -65,14 +65,19 @@ const NewRoute: React.FC<Props> = ({
|
|||
appState.weaponKeys = context.weaponKeys
|
||||
}
|
||||
appState.version = version
|
||||
}, [])
|
||||
}, [context, version])
|
||||
|
||||
useEffect(() => {
|
||||
// Clean state
|
||||
const resetState = clonedeep(initialAppState)
|
||||
Object.keys(resetState).forEach((key) => {
|
||||
appState[key] = resetState[key]
|
||||
})
|
||||
appState.party = resetState.party
|
||||
appState.grid = resetState.grid
|
||||
|
||||
// Old method kept in case we need it later
|
||||
// Object.keys(resetState).forEach((key) => {
|
||||
// appState[key] = resetState[key]
|
||||
// })
|
||||
|
||||
// Set party to be editable
|
||||
appState.party.editable = true
|
||||
}, [])
|
||||
|
|
|
|||
Loading…
Reference in a new issue