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

Check if document is defined (SSR support) #40

Merged
merged 1 commit into from Oct 21, 2017

Conversation

romanenko
Copy link
Contributor

@romanenko romanenko commented Oct 12, 2017

Hi. First of all, thanks for the great and a pretty minimalistic lib. It is a rare case of a useful lib for React with just plain HOCs, a foundation, to be able to construct something completely custom.

I've added type checks for document object in fullscreen functions make this library useful in SSR environments and toolkits like Gatsby, Next.js or Razzle.

It should fix #26, #17, #31

I've tested my PR locally: with these changes it works fine server-side.

@@ -1,4 +1,8 @@
export default (() => {
if (typeof document === 'undefined') {
return () => {}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've decided to go with early return and no-op function here, because this function still expected to return some function anyway. Without document it is reasonable, that the resulting function could be simply empty

@souporserious
Copy link
Owner

Thank you for this 🙏 also, I appreciate the kind words! 😊

@souporserious souporserious merged commit 0d29b7c into souporserious:master Oct 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Server side rendering support
2 participants