createResource returns undefined
Hello, goodnight everyone. Im having a problem using createResource. This function returns me undefined whenever I try to log it
(console.log(data()))
. I tested to see that this wasn't an issue in my API by logging the response in the fetcher function and everything was as expected. The strangest thing is that I can normally render the result of this resource even though it is undefined.
4 Replies
The resource is undefined initially lf you are console logging in a non reactive scope, like outside the JSX or not in an effect, it will log undefined and won't react to when the resource resolves
an example:
Oh I didn't know that. Thank you 👏
Just stumbled upon the same issue. Very helpful to me as well! Thanks!