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

SSR compatibility patch #37

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

eghan
Copy link

@eghan eghan commented Nov 29, 2018

Working with Gatsby the window property assignment works fine in development build but fails in deployment builds because 'window' is not available. Simple conditional assignment I am presuming preferable to componentDidMount style solutions as unintended side effects are minimized.

Thanks for this fantastic repo! works great(almost!) with Gatsby where all other paypal solutions seem to fail

calling to window properties causes React SSR pre-render compiles to fail, this change will add compatibility for 'Gatsby build' and similar
calling to window properties causes React SSR pre-render compiles to fail, this change will add compatibility for 'Gatsby build' and similar
@dderooy
Copy link

dderooy commented Jan 15, 2019

I have the same issue! Thanks for creating a PR for this. @thinhvo0108 can you approve this?

@thinhvo0108
Copy link
Owner

thinhvo0108 commented Jan 16, 2019 via email

@aralroca
Copy link

My question is: Why is necessary to add React and ReactDOM to window object? 😕At least, if this is absolute necessary... should be clean it on unmount...

componentWillUnMount(){
  delete window.React
  delete window.ReactDOM
}

@Flatheadman
Copy link

Yeah, componentDidMount style solution does work.

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.

5 participants