Hi all, we are getting a new error with `Attribute...
# gooddata-ui
k
Hi all, we are getting a new error with
AttributeFilterButton
on a nextjs webapp. On a client-side rendered page, if we add the element, then we get the following error. This does not happen if we add a
DateFilter
fwiw. While this works locally even with the error eventually, it does not pass the production build scripts because of this error. Any insight as to what might be causing this specific element to error out when building a custom UI?
Copy code
⨯ ReferenceError: document is not defined
1
here is an example project showing the error
it fails in two scenarios: 1. loading the page 2. trying to do a production build but the date filter is fine
r
Hi there Kyle, Radek from the GD Technical team, this has been brought to my attention - checking and will come back to you! 🙂
k
awesome, thank you!
hopefully the demo helps a bit
r
Well, I did clone it and replaced the refs to point to my testing workspace and data, and besides React complaining about 'UNSAFE_componentWillReceiveProps in strict mode is not recommended', everything seems to be fine 😅
k
you were able to run
npm run build
without it throwing an error?
r
ah right, build is unhappy, that's.. well, good news in this context 🙂
k
😅
r
Ohh, I think it might be SSR-related, GD.UI doesn't actually support SSR - but still double-checking if I'm right!
k
yeah, thats why i have the
use client
and i am able to load the InsightView just fine too (there is another bug we discussed a few weeks ago about InsightView and nextjs using dynamic routes)
just you saying that reminded me of the fix
Copy code
import dynamic from 'next/dynamic';

const DateFilter = dynamic(() => import('@gooddata/sdk-ui-filters').then(mod => mod.DateFilter), {
  ssr: false
});

const AttributeFilterButton = dynamic(() => import('@gooddata/sdk-ui-filters').then(mod => mod.AttributeFilterButton), {
  ssr: false
});
r
Just got to the same point, exactly!
k
need to use dynamic to ensure that SSR isn't used during nextjs build
haha great minds think alike!
r
Was able to get it to build that way, yep 🙂
k
okay thank you!
sorry about that
r
Oh no worries, happy to help Kyle!