Open 610 opened 1 year ago
This has nothing to do with storefront-data-hooks
, that appears to be the same behavior for all useSWR
hooks I have. Closing this issue.
Nope, wrong again :)
My other useSWR
hooks work in all components. Custom implemented useCustomer
also works. But whenever I try to use useCustomer
from storefront-data-hooks
- it always returns undefined
.....
I noticed that swr
in storefront-data-hooks
is very outdated - 0.3.6
, which has been released more than 2 years ago.
The same applies to the https://github.com/storyblok/nextjs-bigcommerce-starter template, which is using the older swr and nextjs 10. Could it be because of version incompatibility? I'm using the latest next and swr in my project.
I'm having a problem using storefront hooks. After successful SSO login and having all the api endpoints on NextJS application for BigCommerce in place, the hooks return
undefined
result on the first page load, even though if I look into the Network tab of the browser, I can see SWR does successful requests to/api/bigcommerce/customers
and this endpoint returns logged in user data.Whats interesting, if I update a code and NextJS running in development mode will refresh the page in browser automatically, the hook returns data as expected. But then if I refresh the page manually again, it returns
undefined
.On the first call of
useCustomer
I can see api request in the Network tab to the/api/bigcommerce/customers
endpoint, which returns expected data.I have also tried to revalidate the cache, but it also doesn't help.
The same problem with
useCart
hook.It looks like hooks don't revalidate SWR cache properly. Does anyone experience the same issue? I have already read all issues/topics and debugged everything as much as possible.
Package versions: