From bf44bce954eed7cea324e2a8357a04504d98059a Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Sun, 13 Jan 2019 21:23:49 -0500 Subject: [PATCH] Moving propTypes into class definitions --- src/components/App/index.js | 20 +++++++++--------- src/components/Form/index.js | 28 +++++++++++++------------- src/components/FormActions/index.js | 18 ++++++++--------- src/components/Render/index.js | 10 ++++----- src/components/SentryBoundary/index.js | 14 ++++++------- 5 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/components/App/index.js b/src/components/App/index.js index f7e2295..1836d74 100644 --- a/src/components/App/index.js +++ b/src/components/App/index.js @@ -15,6 +15,16 @@ class App extends React.PureComponent { render: {} } + propTypes = { + syntax: PropTypes.string, + expr: PropTypes.string, + permalinkUrl: PropTypes.string, + syntaxList: PropTypes.arrayOf(PropTypes.shape({ + id: PropTypes.string, + label: PropTypes.string + })) + } + componentDidMount() { if (this.props.expr) { this.handleRender(); @@ -144,14 +154,4 @@ class App extends React.PureComponent { } } -App.propTypes = { - syntax: PropTypes.string, - expr: PropTypes.string, - permalinkUrl: PropTypes.string, - syntaxList: PropTypes.arrayOf(PropTypes.shape({ - id: PropTypes.string, - label: PropTypes.string - })) -}; - export default App; diff --git a/src/components/Form/index.js b/src/components/Form/index.js index 8aae38a..42a4eba 100644 --- a/src/components/Form/index.js +++ b/src/components/Form/index.js @@ -11,6 +11,20 @@ class Form extends React.PureComponent { syntax: this.props.syntax } + propTypes = { + expr: PropTypes.string, + syntax: PropTypes.string, + syntaxList: PropTypes.arrayOf(PropTypes.shape({ + id: PropTypes.string, + label: PropTypes.string + })), + onSubmit: PropTypes.func.isRequired, + children: PropTypes.oneOfType([ + PropTypes.arrayOf(PropTypes.node), + PropTypes.node + ]) + } + handleSubmit = event => { event.preventDefault(); @@ -63,18 +77,4 @@ class Form extends React.PureComponent { } } -Form.propTypes = { - expr: PropTypes.string, - syntax: PropTypes.string, - syntaxList: PropTypes.arrayOf(PropTypes.shape({ - id: PropTypes.string, - label: PropTypes.string - })), - onSubmit: PropTypes.func.isRequired, - children: PropTypes.oneOfType([ - PropTypes.arrayOf(PropTypes.node), - PropTypes.node - ]) -}; - export default Form; diff --git a/src/components/FormActions/index.js b/src/components/FormActions/index.js index 7e1df29..df39060 100644 --- a/src/components/FormActions/index.js +++ b/src/components/FormActions/index.js @@ -14,6 +14,15 @@ class FormActions extends React.PureComponent { pngLink: null } + propTypes = { + permalinkUrl: PropTypes.string, + imageDetails: PropTypes.shape({ + svg: PropTypes.string, + width: PropTypes.number, + height: PropTypes.number + }) + } + componentDidMount() { const { imageDetails } = this.props; @@ -80,13 +89,4 @@ class FormActions extends React.PureComponent { } } -FormActions.propTypes = { - permalinkUrl: PropTypes.string, - imageDetails: PropTypes.shape({ - svg: PropTypes.string, - width: PropTypes.number, - height: PropTypes.number - }) -}; - export default FormActions; diff --git a/src/components/Render/index.js b/src/components/Render/index.js index 3785003..becb08a 100644 --- a/src/components/Render/index.js +++ b/src/components/Render/index.js @@ -6,6 +6,11 @@ import PlaceholderIcon from 'react-feather/dist/icons/file-text'; import style from './style.module.css'; class Render extends React.PureComponent { + propTypes = { + expr: PropTypes.string, + onRender: PropTypes.func.isRequired + } + svgContainer = React.createRef() provideSVGData() { @@ -42,9 +47,4 @@ class Render extends React.PureComponent { } } -Render.propTypes = { - expr: PropTypes.string, - onRender: PropTypes.func.isRequired -}; - export default Render; diff --git a/src/components/SentryBoundary/index.js b/src/components/SentryBoundary/index.js index e814389..41c4b71 100644 --- a/src/components/SentryBoundary/index.js +++ b/src/components/SentryBoundary/index.js @@ -9,6 +9,13 @@ class SentryBoundary extends React.Component { hasError: false } + propTypes = { + children: PropTypes.oneOfType([ + PropTypes.arrayOf(PropTypes.node), + PropTypes.node + ]).isRequired + } + static getDerivedStateFromError() { return { hasError: true }; } @@ -33,11 +40,4 @@ class SentryBoundary extends React.Component { } } -SentryBoundary.propTypes = { - children: PropTypes.oneOfType([ - PropTypes.arrayOf(PropTypes.node), - PropTypes.node - ]).isRequired -}; - export default SentryBoundary;