Skip to content

Commit

Permalink
refactor: stop scope before unmounted hook
Browse files Browse the repository at this point in the history
  • Loading branch information
sibbng committed Mar 7, 2022
1 parent ed6e6e1 commit d0580cf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/react.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@ export function useSetup<State, Props = {}>(
invokeLifecycle(LifecycleHooks.MOUNTED)
return () => {
invokeLifecycle(LifecycleHooks.BEFORE_UNMOUNT)
scope.current?.cleanups.forEach(fn => fn())
process.env.NODE_ENV !== 'development'
? scope.current?.stop()
: scope.current?.cleanups.forEach(fn => fn())
invokeLifecycle(LifecycleHooks.UNMOUNTED)
setMountState(false)
process.env.NODE_ENV !== 'development' && scope.current?.stop()
}
}, [])

Expand Down
2 changes: 1 addition & 1 deletion src/solid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ export function useSetup<State, Props = {}>(

onCleanup(() => {
invokeLifecycle(LifecycleHooks.BEFORE_UNMOUNT)
scope.stop()
invokeLifecycle(LifecycleHooks.UNMOUNTED)
setMountState(false)
scope.stop()
})

return state as ReturnedSetup<State>
Expand Down

0 comments on commit d0580cf

Please sign in to comment.