-
-
Notifications
You must be signed in to change notification settings - Fork 42
[bug] Purity flags instantiating refs with new AbortController() #1625
Copy link
Copy link
Closed
Labels
Status: ReleasedThe issue has been releasedThe issue has been releasedType: BugSomething isn't workingSomething isn't working
Description
Describe the bug
Constructing an AbortController triggers the purity rule, even though it is a pure operation
Reproduction
export function useMyHook() {
// flags for purity:
const abortControllerRef = useRef(new AbortController());
// also flags: pattern from https://react.dev/reference/react/useRef#avoiding-recreating-the-ref-contents
const abortControllerRef2 = useRef<AbortController>(null);
if (abortControllerRef2.current === null) {
abortControllerRef2.current = new AbortController();
}
// Does not flag: equivalent useState initializer:
const abortController = useState(() => new AbortController());
}Expected behavior
None of the above examples should flag for purity
Platform and versions
plugin 3.0.0 stable; node 24
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Status: ReleasedThe issue has been releasedThe issue has been releasedType: BugSomething isn't workingSomething isn't working