Skip to content
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

"ReferenceError: document is not defined" in SSR #6

Closed
frepps opened this issue Mar 31, 2020 · 2 comments · Fixed by #7
Closed

"ReferenceError: document is not defined" in SSR #6

frepps opened this issue Mar 31, 2020 · 2 comments · Fixed by #7
Labels
bug Something isn't working

Comments

@frepps
Copy link

frepps commented Mar 31, 2020

Hello, and thank you for your work on this component!

I get a "document is not defined" error on the server when I am using server side rendering.

It looks like the problem is here:

const containerRef = useRef<HTMLDivElement>(document.createElement('div'));

I tried to fork the project an replace
const containerRef = useRef<HTMLDivElement>(document.createElement('div'));
with
const containerRef = useRef<HTMLDivElement>(null);
and add null-checks whenever containerRef.current is used, but my experience with typescript is limited and I didn't want to make a mess! 😀

@nerdyman
Copy link
Owner

Hi @frepps, thanks for opening the issue!

I'll need to change a few things to get it working with SSR since the library uses document and window in several places. I'll get cracking on a fix.

@nerdyman nerdyman added bug Something isn't working enhancement New feature or request and removed enhancement New feature or request labels Mar 31, 2020
@nerdyman nerdyman linked a pull request Apr 4, 2020 that will close this issue
@nerdyman
Copy link
Owner

nerdyman commented Apr 5, 2020

@frepps SSR support has been added in 1.0.3, thanks for reporting the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants