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

Don't crash app when server-side rendering #36

Closed
jazoom opened this issue Mar 3, 2017 · 4 comments
Closed

Don't crash app when server-side rendering #36

jazoom opened this issue Mar 3, 2017 · 4 comments

Comments

@jazoom
Copy link

jazoom commented Mar 3, 2017

I just did something crude like returning a dummy component and that seems to work. You'll probably be able to think of a more sensible implementation. This is what I did:

(function (global, factory) {
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
    typeof define === 'function' && define.amd ? define(factory) :
      (global.VueRecaptcha = factory());
}(this, (function () {
  'use strict';

  // *************** CHANGED ***************
  if (typeof window == 'undefined') {
    console.log('RETURNING DUMMY COMPONENT...');
    return {
      name: 'VueRecaptcha',
      render: function render(h) {
        return h(
          'div',
          { ref: 'container' },
          []
        );
      }
    };;
  }
  // ***************************************

  var _extends = Object.assign || function (target) {
    for (var i = 1; i < arguments.length; i++) {
      var source = arguments[i];

      for (var key in source) {
        if (Object.prototype.hasOwnProperty.call(source, key)) {
          target[key] = source[key];
        }
      }
    }

    return target;
  };

  var defer = function defer() {....... <the rest of the code beyond here>...
@DanSnow
Copy link
Owner

DanSnow commented Mar 3, 2017

Thanks for reporting issue.
I haven't used server-side rendering before.
I can take a look this weekend.

@DanSnow
Copy link
Owner

DanSnow commented Mar 4, 2017

@jazoom
I have implemented in current HEAD.
May you try it in your app to help me confirm that it work correctly?
I will publish the new version tomorrow at latest.

@DanSnow
Copy link
Owner

DanSnow commented Mar 5, 2017

v0.3.3 has been published.

@DanSnow DanSnow closed this as completed Mar 5, 2017
@jazoom
Copy link
Author

jazoom commented Mar 12, 2017

Sorry for the late reply. Yes, it appears to work well. Thank you.

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

No branches or pull requests

2 participants