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

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

@yossisp

Description

@yossisp

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions