From 7aac749d775344cb9a1b5f363d0f3bfb06460dba Mon Sep 17 00:00:00 2001 From: casperlamboo Date: Tue, 14 Nov 2017 13:49:31 +0100 Subject: [PATCH] move static props --- src/components/AuthImage.js | 21 +++++++--------- src/components/DoodlePreview.js | 43 ++++++++++++++++----------------- 2 files changed, 30 insertions(+), 34 deletions(-) diff --git a/src/components/AuthImage.js b/src/components/AuthImage.js index 05df41a..d62dce0 100644 --- a/src/components/AuthImage.js +++ b/src/components/AuthImage.js @@ -7,13 +7,16 @@ import PouchDB from 'pouchdb'; // const debug = createDebug('d3d:FileThumb'); class AuthImage extends React.Component { - constructor() { - super(); + static propTypes = { + dispatch: PropTypes.func, + src: PropTypes.string.isRequired, + token: PropTypes.string, + password: PropTypes.string + }; - this.state = { - src: null - }; - } + state = { + src: null + }; componentWillMount() { const { src, token, password } = this.props; @@ -55,12 +58,6 @@ class AuthImage extends React.Component { return (); } } -AuthImage.propTypes = { - dispatch: PropTypes.func, - src: PropTypes.string.isRequired, - token: PropTypes.string, - password: PropTypes.string -}; export default connect(state => ({ token: state.user.session.token, diff --git a/src/components/DoodlePreview.js b/src/components/DoodlePreview.js index 5c2f92e..b27bd03 100644 --- a/src/components/DoodlePreview.js +++ b/src/components/DoodlePreview.js @@ -18,12 +18,27 @@ const styles = { }; class DoodlePreview extends React.Component { - constructor() { - super(); - this.state = { - scene: null - }; - } + static defaultProps = { + width: 720, + height: 480, + pixelRatio: 1 + }; + + static propTypes = { + classes: PropTypes.objectOf(PropTypes.string), + width: PropTypes.number.isRequired, + height: PropTypes.number.isRequired, + pixelRatio: PropTypes.number.isRequired, + sketchData: PropTypes.object, // TODO + docData: PropTypes.shape({ + appVersion: PropTypes.string, + data: PropTypes.string + }) + }; + + state = { + scene: null + }; async componentDidMount() { let { docData, sketchData } = this.props; @@ -65,21 +80,5 @@ class DoodlePreview extends React.Component { ); } } -DoodlePreview.defaultProps = { - width: 720, - height: 480, - pixelRatio: 1 -}; -DoodlePreview.propTypes = { - classes: PropTypes.objectOf(PropTypes.string), - width: PropTypes.number.isRequired, - height: PropTypes.number.isRequired, - pixelRatio: PropTypes.number.isRequired, - sketchData: PropTypes.object, // TODO - docData: PropTypes.shape({ - appVersion: PropTypes.string, - data: PropTypes.string - }) -}; export default injectSheet(styles)(DoodlePreview);