I am trying to import a node module React-Signature-Pad. The index.js file looks like this:
import PropTypes from 'prop-types'
import React, { Component } from 'react'
import trimCanvas from 'trim-canvas'
import Bezier from './bezier.js'
import Point from './point.js'
export default class SignatureCanvas extends Component {
static propTypes = {
velocityFilterWeight: PropTypes.number,
minWidth: PropTypes.number,
maxWidth: PropTypes.number,
dotSize: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
penColor: PropTypes.string,
onEnd: PropTypes.func,
onBegin: PropTypes.func,
canvasProps: PropTypes.object
}
static defaultProps = {
velocityFilterWeight: 0.7,
minWidth: 0.5,
maxWidth: 2.5,
dotSize: () => {
return (this.props.minWidth + this.props.maxWidth) / 2
},
penColor: 'black',
backgroundColor: 'rgba(0,0,0,0)',
onEnd: () => {},
onBegin: () => {}
}
componentDidMount () {
this._ctx = this._canvas.getContext("2d");
//.....
I am trying to use it like this: import * as SignatureCanvas from 'react-signature-canvas'
However then SignatureCanvas evaulates to an object with a single property of 'default'. So when I use I get an error because SignatureCanvas is not actually a constructor.
The only way I have been able to get this to work is to import it like this:
declare var require: any;
var SignatureCanvas = require('react-signature-canvas').default;
Which doesn't seem right. Which is the proper way to import?
I am using WebPack2 to bundler the site if it matters.