diff --git a/src/components/App/index.js b/src/components/App/index.js index 1836d74..af5bec3 100644 --- a/src/components/App/index.js +++ b/src/components/App/index.js @@ -9,13 +9,7 @@ import Loader from 'components/Loader'; import Message from 'components/Message'; class App extends React.PureComponent { - state = { - loading: false, - loadingError: null, - render: {} - } - - propTypes = { + static propTypes = { syntax: PropTypes.string, expr: PropTypes.string, permalinkUrl: PropTypes.string, @@ -25,6 +19,12 @@ class App extends React.PureComponent { })) } + state = { + loading: false, + loadingError: null, + render: {} + } + componentDidMount() { if (this.props.expr) { this.handleRender(); diff --git a/src/components/Form/index.js b/src/components/Form/index.js index 42a4eba..ede5f6e 100644 --- a/src/components/Form/index.js +++ b/src/components/Form/index.js @@ -6,12 +6,7 @@ import ExpandIcon from 'react-feather/dist/icons/chevrons-down'; import style from './style.module.css'; class Form extends React.PureComponent { - state = { - expr: this.props.expr, - syntax: this.props.syntax - } - - propTypes = { + static propTypes = { expr: PropTypes.string, syntax: PropTypes.string, syntaxList: PropTypes.arrayOf(PropTypes.shape({ @@ -25,6 +20,11 @@ class Form extends React.PureComponent { ]) } + state = { + expr: this.props.expr, + syntax: this.props.syntax + } + handleSubmit = event => { event.preventDefault(); diff --git a/src/components/FormActions/index.js b/src/components/FormActions/index.js index df39060..00411c1 100644 --- a/src/components/FormActions/index.js +++ b/src/components/FormActions/index.js @@ -9,12 +9,7 @@ import style from './style.module.css'; import { createPngLink, createSvgLink } from './links'; class FormActions extends React.PureComponent { - state = { - svgLink: null, - pngLink: null - } - - propTypes = { + static propTypes = { permalinkUrl: PropTypes.string, imageDetails: PropTypes.shape({ svg: PropTypes.string, @@ -23,6 +18,11 @@ class FormActions extends React.PureComponent { }) } + state = { + svgLink: null, + pngLink: null + } + componentDidMount() { const { imageDetails } = this.props; diff --git a/src/components/Render/index.js b/src/components/Render/index.js index becb08a..3aadb09 100644 --- a/src/components/Render/index.js +++ b/src/components/Render/index.js @@ -6,7 +6,7 @@ import PlaceholderIcon from 'react-feather/dist/icons/file-text'; import style from './style.module.css'; class Render extends React.PureComponent { - propTypes = { + static propTypes = { expr: PropTypes.string, onRender: PropTypes.func.isRequired } diff --git a/src/components/SentryBoundary/index.js b/src/components/SentryBoundary/index.js index 41c4b71..6914f39 100644 --- a/src/components/SentryBoundary/index.js +++ b/src/components/SentryBoundary/index.js @@ -5,17 +5,17 @@ import * as Sentry from '@sentry/browser'; import SentryError from 'components/SentryError'; class SentryBoundary extends React.Component { - state = { - hasError: false - } - - propTypes = { + static propTypes = { children: PropTypes.oneOfType([ PropTypes.arrayOf(PropTypes.node), PropTypes.node ]).isRequired } + state = { + hasError: false + } + static getDerivedStateFromError() { return { hasError: true }; }