Making propTypes static

This commit is contained in:
Jeff Avallone 2019-01-13 21:30:06 -05:00
parent bf44bce954
commit 7261b0b526
5 changed files with 25 additions and 25 deletions

View File

@ -9,13 +9,7 @@ import Loader from 'components/Loader';
import Message from 'components/Message'; import Message from 'components/Message';
class App extends React.PureComponent { class App extends React.PureComponent {
state = { static propTypes = {
loading: false,
loadingError: null,
render: {}
}
propTypes = {
syntax: PropTypes.string, syntax: PropTypes.string,
expr: PropTypes.string, expr: PropTypes.string,
permalinkUrl: PropTypes.string, permalinkUrl: PropTypes.string,
@ -25,6 +19,12 @@ class App extends React.PureComponent {
})) }))
} }
state = {
loading: false,
loadingError: null,
render: {}
}
componentDidMount() { componentDidMount() {
if (this.props.expr) { if (this.props.expr) {
this.handleRender(); this.handleRender();

View File

@ -6,12 +6,7 @@ import ExpandIcon from 'react-feather/dist/icons/chevrons-down';
import style from './style.module.css'; import style from './style.module.css';
class Form extends React.PureComponent { class Form extends React.PureComponent {
state = { static propTypes = {
expr: this.props.expr,
syntax: this.props.syntax
}
propTypes = {
expr: PropTypes.string, expr: PropTypes.string,
syntax: PropTypes.string, syntax: PropTypes.string,
syntaxList: PropTypes.arrayOf(PropTypes.shape({ 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 => { handleSubmit = event => {
event.preventDefault(); event.preventDefault();

View File

@ -9,12 +9,7 @@ import style from './style.module.css';
import { createPngLink, createSvgLink } from './links'; import { createPngLink, createSvgLink } from './links';
class FormActions extends React.PureComponent { class FormActions extends React.PureComponent {
state = { static propTypes = {
svgLink: null,
pngLink: null
}
propTypes = {
permalinkUrl: PropTypes.string, permalinkUrl: PropTypes.string,
imageDetails: PropTypes.shape({ imageDetails: PropTypes.shape({
svg: PropTypes.string, svg: PropTypes.string,
@ -23,6 +18,11 @@ class FormActions extends React.PureComponent {
}) })
} }
state = {
svgLink: null,
pngLink: null
}
componentDidMount() { componentDidMount() {
const { imageDetails } = this.props; const { imageDetails } = this.props;

View File

@ -6,7 +6,7 @@ import PlaceholderIcon from 'react-feather/dist/icons/file-text';
import style from './style.module.css'; import style from './style.module.css';
class Render extends React.PureComponent { class Render extends React.PureComponent {
propTypes = { static propTypes = {
expr: PropTypes.string, expr: PropTypes.string,
onRender: PropTypes.func.isRequired onRender: PropTypes.func.isRequired
} }

View File

@ -5,17 +5,17 @@ import * as Sentry from '@sentry/browser';
import SentryError from 'components/SentryError'; import SentryError from 'components/SentryError';
class SentryBoundary extends React.Component { class SentryBoundary extends React.Component {
state = { static propTypes = {
hasError: false
}
propTypes = {
children: PropTypes.oneOfType([ children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node), PropTypes.arrayOf(PropTypes.node),
PropTypes.node PropTypes.node
]).isRequired ]).isRequired
} }
state = {
hasError: false
}
static getDerivedStateFromError() { static getDerivedStateFromError() {
return { hasError: true }; return { hasError: true };
} }