You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
const { data: customer } = useCustomer(); // It gets invoked in the component at least 2 times.
console.log(customer); // <--- is undefined on first page load, and returns data only if NextJS
// refreshes the page automatically after code change.
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.
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:
@bigcommerce/storefront-data-hooks@^1.7.0
next@^12.3.1
react@^18.1.0
swr@^1.3.0
The text was updated successfully, but these errors were encountered:
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:
The text was updated successfully, but these errors were encountered: