From 47f41a19a0213021960a3c8e6827959f773a43d7 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sun, 10 Apr 2022 13:06:44 -0700 Subject: [PATCH] Fix memory leak --- components/Party/index.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/Party/index.tsx b/components/Party/index.tsx index b00c1104..eb5a0695 100644 --- a/components/Party/index.tsx +++ b/components/Party/index.tsx @@ -39,21 +39,21 @@ const Party = (props: Props) => { // Set up states const { party } = useSnapshot(appState) + const jobState = party.job const [job, setJob] = useState() const [currentTab, setCurrentTab] = useState(GridType.Weapon) - // Update job when state changes - subscribeKey(appState.party, 'job', (value: Job) => { - setJob(value) - }) - // Reset state on first load useEffect(() => { const resetState = clonedeep(initialAppState) appState.grid = resetState.grid }, []) + useEffect(() => { + setJob(jobState) + }, [jobState]) + useEffect(() => { jobChanged() }, [job])