Skip to content
This repository has been archived by the owner on May 21, 2020. It is now read-only.

Setting width in the API doesn't work serverside #60

Open
yossisp opened this issue Dec 23, 2019 · 0 comments
Open

Setting width in the API doesn't work serverside #60

yossisp opened this issue Dec 23, 2019 · 0 comments

Comments

@yossisp
Copy link

yossisp commented Dec 23, 2019

The following code:

import MotionDrawer from 'react-motion-drawer';
<MotionDrawer
          open={open}
          width="100%"
          zIndex={10}
          onChange={handleChange}
>
  // content    
</MotionDrawer>

will throw the following error when using the library serverside:

ReferenceError: document is not defined
    at Drawer._this.calculateWidth (node_modules/react-motion-drawer/drawer.js:132:34)

This happens because in drawer.js:132:34 there's no document when you're not clientside.

_this.calculateWidth = function () {
      var width = _this.props.width;
      return (/\D/.test(width) ? document.body.clientWidth * (width.match(/\d*/) / 100) : width
      );
}

I saw that a similar error was already fixed so it would be nice if this one could be also fixed. Thanks in advance!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant