Skip to content

Commit

Permalink
fix: remove unreachable code branches
Browse files Browse the repository at this point in the history
  • Loading branch information
hlysine committed May 31, 2023
1 parent 4eb97a2 commit 30c4de1
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,10 @@ export const useComputed: UseComputed = (<T>(
// eslint-disable-next-line react-hooks/rules-of-hooks
useEffect(() => {
return () => {
reactiveRef.current?.effect.stop();
reactiveRef.current = null;
if (reactiveRef.current !== null) {
reactiveRef.current.effect.stop();
reactiveRef.current = null;
}
};
}, []);
}
Expand Down Expand Up @@ -321,8 +323,10 @@ export const useWatchEffect = (
// eslint-disable-next-line react-hooks/rules-of-hooks
useEffect(() => {
return () => {
reactiveRef.current?.effect.stop();
reactiveRef.current = null;
if (reactiveRef.current !== null) {
reactiveRef.current.effect.stop();
reactiveRef.current = null;
}
};
}, []);
}
Expand Down Expand Up @@ -474,9 +478,6 @@ export const watch: WatchOverloads = <
// eslint-disable-next-line prefer-const
let effect: ReactiveEffectRunner<any>;
const job = () => {
if (!effect.effect.active) {
return;
}
const newValue = effect();
if (
deep ||
Expand Down Expand Up @@ -607,8 +608,10 @@ export const useWatch: UseWatchOverloads = <
// eslint-disable-next-line react-hooks/rules-of-hooks
useEffect(() => {
return () => {
reactiveRef.current?.();
reactiveRef.current = null;
if (reactiveRef.current !== null) {
reactiveRef.current();
reactiveRef.current = null;
}
};
}, []);
}
Expand Down

0 comments on commit 30c4de1

Please sign in to comment.