HubSpot/drop

NodeJS support

Opened this issue · 1 comments

It would be great if Drop.js could also render on the server with React.js. Currently it cannot even be imported because document wouldn't be defined. That would require the initial document uses to be wrapped by something like if (typeof window !== 'undefined') { ... }.

Use the require function to import tether drop in the componentDidMount function.

componentDidMount() {
  const Drop = require('tether-drop');
  this.dropInstance = new Drop({
    target: document.querySelector('.drop-target'),
    content: 'Welcome to the future',
    classes: 'drop-theme-arrows',
    position: 'bottom left',
    openOn: 'click'
  });
}