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';
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();

View File

@ -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();

View File

@ -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;

View File

@ -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
}

View File

@ -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 };
}