Skip to content

Commit

Permalink
fix: full rewrite of ScopeProvider to address known issues
Browse files Browse the repository at this point in the history
- fixes: #25, #36
  • Loading branch information
dmaskasky committed Sep 25, 2024
1 parent a027650 commit 3788511
Show file tree
Hide file tree
Showing 41 changed files with 2,130 additions and 924 deletions.
54 changes: 22 additions & 32 deletions __tests__/derive/baseTests/react/abortable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,24 @@ describe('abortable atom test', () => {
const resolve: (() => void)[] = [];
const derivedAtom = atom(async (get, { signal }) => {
const count = get(countAtom);
await new Promise<void>((r) => resolve.push(r));
await new Promise<void>((r) => {
resolve.push(r);
});
if (signal.aborted) {
++abortedCount;
}
return count;
});

const Component = () => {
function Component() {
const count = useAtomValue(derivedAtom);
return <div>count: {count}</div>;
};
}

const Controls = () => {
function Controls() {
const setCount = useSetAtom(countAtom);
return (
<>
<button onClick={() => setCount((c) => c + 1)}>button</button>
</>
);
};
return <button onClick={() => setCount((c) => c + 1)}>button</button>;
}

const { findByText, getByText } = render(
<StrictMode>
Expand Down Expand Up @@ -75,19 +73,15 @@ describe('abortable atom test', () => {
return count;
});

const Component = () => {
function Component() {
const count = useAtomValue(derivedAtom);
return <div>count: {count}</div>;
};
}

const Controls = () => {
function Controls() {
const setCount = useSetAtom(countAtom);
return (
<>
<button onClick={() => setCount((c) => c + 1)}>button</button>
</>
);
};
return <button onClick={() => setCount((c) => c + 1)}>button</button>;
}

const { findByText, getByText } = render(
<StrictMode>
Expand Down Expand Up @@ -131,12 +125,12 @@ describe('abortable atom test', () => {
return count;
});

const Component = () => {
function Component() {
const count = useAtomValue(derivedAtom);
return <div>count: {count}</div>;
};
}

const Parent = () => {
function Parent() {
const setCount = useSetAtom(countAtom);
const [show, setShow] = useState(true);
return (
Expand All @@ -146,7 +140,7 @@ describe('abortable atom test', () => {
<button onClick={() => setShow((x) => !x)}>toggle</button>
</>
);
};
}

const { findByText, getByText } = render(
<StrictMode>
Expand Down Expand Up @@ -183,19 +177,15 @@ describe('abortable atom test', () => {
return count;
});

const Component = () => {
function Component() {
const count = useAtomValue(derivedAtom);
return <div>count: {count}</div>;
};
}

const Controls = () => {
function Controls() {
const setCount = useSetAtom(countAtom);
return (
<>
<button onClick={() => setCount((c) => c + 1)}>button</button>
</>
);
};
return <button onClick={() => setCount((c) => c + 1)}>button</button>;
}

const { findByText, getByText } = render(
<StrictMode>
Expand Down
Loading

0 comments on commit 3788511

Please sign in to comment.