-
-
Notifications
You must be signed in to change notification settings - Fork 413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Server Error ReferenceError: document is not defined #859
Comments
Ugh yea. |
I just spent several days porting over to this library and have had good results with it. All was great until I got to the very last table, it needs pagination. Yep I am using SSR via next.js. So here I am... You can check for if (typeof window === 'object') {
... use document here
} My hack around this for now is to check for the presence of document as above, and then to set the pagination property conditionally based on this. So this renders as not paginated on the server but paginated on the client. |
@jeffdc thank you this is helpful. I'll fix in the |
A fix for this is now available in 7.0.0-rc4. The fix was to implement a check for Please let me know if this resolves the issue as I don't have a nextjs environment setup at the moment. What I am not able to test is if RTL still works completely in SSR scenarios. |
It seems to work but I have a new warning from the server-side that may or may not be a result of this change. I think that it is probably not from this change but will let you know once I figure it out. Thanks for the quick fix. The warning is: |
The warning does come from this component. It only shows up when I have pagination on. So the change does introduce this warning but fixes the previous error. It seems to originate in styled-components. I found this SO post which talks about a similar issue. The stack for the warning:
|
Everything is fine. Whenever Pagination property set true then error occurred. Using dependency
"bootstrap": "^5.0.2",
"next": "11.0.1",
"nextjs-progressbar": "0.0.11",
"react": "17.0.2",
"react-bootstrap": "^2.0.0-beta.4",
"react-data-table-component": "^7.0.0-rc2",
"react-dom": "17.0.2",
"recharts": "^2.0.10",
"styled-components": "^5.3.0"
Here is the error
The text was updated successfully, but these errors were encountered: