MCPcopy Create free account
hub / github.com/async-library/react-async / App

Function App

packages/react-async/src/useAsync.spec.js:60–77  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

58 const promiseFn = jest.fn(() => resolveTo())
59 const deferFn = () => resolveTo()
60 function App() {
61 const [count, setCount] = React.useState(0)
62 const { reload } = useAsync({
63 promiseFn,
64 count,
65 watch: count,
66 })
67 const { run } = useAsync({
68 deferFn,
69 onResolve: reload,
70 })
71 return (
72 <div>
73 <button onClick={() => setCount(n => n + 1)}>inc</button>
74 <button onClick={() => run()}>run</button>
75 </div>
76 )
77 }
78 const { getByText } = render(<App />)
79 expect(promiseFn).toHaveBeenLastCalledWith(expect.objectContaining({ count: 0 }), abortCtrl)
80 fireEvent.click(getByText("inc"))

Callers

nothing calls this directly

Calls 2

useAsyncFunction · 0.85
runFunction · 0.85

Tested by

no test coverage detected