SolidJSS
SolidJS2y ago
37 replies
smushball

Await a resource inside a function?

This there a function which achieves something similar as my fictional "waitForResource" function here?

Or should I refactor my code?

const myResource = createResource(...)

const handleSubmit = async () => {
  const data = myResource(); // T | undefined

  const data = await waitForResource(myResource()); // T
}

return (
  <form onSubmit={handleSubmit}>...
Was this page helpful?