Beginning to reformat propTypes and set redux, intl functions to end of component files
• Beginning: - to reformat propTypes and set redux, intl functions to end of component files
This commit is contained in:
@@ -7,45 +7,11 @@ import {
|
||||
fetchBundleFail,
|
||||
} from '../../../actions/bundles'
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
onFetch() {
|
||||
dispatch(fetchBundleRequest())
|
||||
},
|
||||
onFetchSuccess() {
|
||||
dispatch(fetchBundleSuccess())
|
||||
},
|
||||
onFetchFail(error) {
|
||||
dispatch(fetchBundleFail(error))
|
||||
},
|
||||
})
|
||||
|
||||
const emptyComponent = () => null
|
||||
const noop = () => { }
|
||||
|
||||
export default
|
||||
@connect(null, mapDispatchToProps)
|
||||
class Bundle extends React.PureComponent {
|
||||
|
||||
static propTypes = {
|
||||
fetchComponent: PropTypes.func.isRequired,
|
||||
loading: PropTypes.func,
|
||||
error: PropTypes.func,
|
||||
children: PropTypes.func.isRequired,
|
||||
renderDelay: PropTypes.number,
|
||||
onFetch: PropTypes.func,
|
||||
onFetchSuccess: PropTypes.func,
|
||||
onFetchFail: PropTypes.func,
|
||||
}
|
||||
|
||||
static defaultProps = {
|
||||
loading: emptyComponent,
|
||||
error: emptyComponent,
|
||||
renderDelay: 0,
|
||||
onFetch: noop,
|
||||
onFetchSuccess: noop,
|
||||
onFetchFail: noop,
|
||||
}
|
||||
|
||||
static cache = new Map
|
||||
|
||||
state = {
|
||||
@@ -145,3 +111,37 @@ class Bundle extends React.PureComponent {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
onFetch() {
|
||||
dispatch(fetchBundleRequest())
|
||||
},
|
||||
onFetchSuccess() {
|
||||
dispatch(fetchBundleSuccess())
|
||||
},
|
||||
onFetchFail(error) {
|
||||
dispatch(fetchBundleFail(error))
|
||||
},
|
||||
})
|
||||
|
||||
Bundle.propTypes = {
|
||||
fetchComponent: PropTypes.func.isRequired,
|
||||
loading: PropTypes.func,
|
||||
error: PropTypes.func,
|
||||
children: PropTypes.func.isRequired,
|
||||
renderDelay: PropTypes.number,
|
||||
onFetch: PropTypes.func,
|
||||
onFetchSuccess: PropTypes.func,
|
||||
onFetchFail: PropTypes.func,
|
||||
}
|
||||
|
||||
Bundle.defaultProps = {
|
||||
loading: emptyComponent,
|
||||
error: emptyComponent,
|
||||
renderDelay: 0,
|
||||
onFetch: noop,
|
||||
onFetchSuccess: noop,
|
||||
onFetchFail: noop,
|
||||
}
|
||||
|
||||
export default connect(null, mapDispatchToProps)(Bundle)
|
||||
@@ -13,12 +13,6 @@ const extractValue = (value) => {
|
||||
|
||||
class ReducedMotion extends React.PureComponent {
|
||||
|
||||
static propTypes = {
|
||||
defaultStyle: PropTypes.object,
|
||||
style: PropTypes.object,
|
||||
children: PropTypes.func,
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
const { style, defaultStyle, children } = this.props;
|
||||
@@ -41,4 +35,10 @@ class ReducedMotion extends React.PureComponent {
|
||||
|
||||
}
|
||||
|
||||
export default ReducedMotion;
|
||||
ReducedMotion.propTypes = {
|
||||
defaultStyle: PropTypes.object,
|
||||
style: PropTypes.object,
|
||||
children: PropTypes.func,
|
||||
}
|
||||
|
||||
export default ReducedMotion
|
||||
|
||||
@@ -11,16 +11,7 @@ import { getWindowDimension } from '../../../utils/is_mobile'
|
||||
|
||||
const initialState = getWindowDimension()
|
||||
|
||||
export default class ResponsiveClassesComponent extends React.PureComponent {
|
||||
|
||||
static propTypes = {
|
||||
classNames: PropTypes.string,
|
||||
classNamesXL: PropTypes.string,
|
||||
classNamesLarge: PropTypes.string,
|
||||
classNamesMedium: PropTypes.string,
|
||||
classNamesSmall: PropTypes.string,
|
||||
classNamesXS: PropTypes.string,
|
||||
}
|
||||
class ResponsiveClassesComponent extends React.PureComponent {
|
||||
|
||||
state = {
|
||||
width: initialState.width,
|
||||
@@ -75,4 +66,15 @@ export default class ResponsiveClassesComponent extends React.PureComponent {
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ResponsiveClassesComponent.propTypes = {
|
||||
classNames: PropTypes.string,
|
||||
classNamesXL: PropTypes.string,
|
||||
classNamesLarge: PropTypes.string,
|
||||
classNamesMedium: PropTypes.string,
|
||||
classNamesSmall: PropTypes.string,
|
||||
classNamesXS: PropTypes.string,
|
||||
}
|
||||
|
||||
export default ResponsiveClassesComponent
|
||||
@@ -4,17 +4,7 @@ import { getWindowDimension } from '../../../utils/is_mobile'
|
||||
|
||||
const initialState = getWindowDimension()
|
||||
|
||||
export default class Responsive extends React.PureComponent {
|
||||
|
||||
static propTypes = {
|
||||
min: PropTypes.number,
|
||||
max: PropTypes.number,
|
||||
}
|
||||
|
||||
static defaultProps = {
|
||||
min: 0,
|
||||
max: Infinity,
|
||||
}
|
||||
class Responsive extends React.PureComponent {
|
||||
|
||||
state = {
|
||||
width: initialState.width,
|
||||
@@ -48,4 +38,16 @@ export default class Responsive extends React.PureComponent {
|
||||
return shouldRender ? children : null
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Responsive.propTypes = {
|
||||
min: PropTypes.number,
|
||||
max: PropTypes.number,
|
||||
}
|
||||
|
||||
Responsive.defaultProps = {
|
||||
min: 0,
|
||||
max: Infinity,
|
||||
}
|
||||
|
||||
export default Responsive
|
||||
@@ -6,18 +6,7 @@ import BundleColumnError from '../../../components/bundle_column_error'
|
||||
import Bundle from './bundle'
|
||||
import { me } from '../../../initial_state'
|
||||
|
||||
export default class WrappedRoute extends React.PureComponent {
|
||||
static propTypes = {
|
||||
component: PropTypes.func.isRequired,
|
||||
page: PropTypes.func.isRequired,
|
||||
content: PropTypes.node,
|
||||
componentParams: PropTypes.object,
|
||||
publicRoute: PropTypes.bool,
|
||||
}
|
||||
|
||||
static defaultProps = {
|
||||
componentParams: {},
|
||||
}
|
||||
class WrappedRoute extends React.PureComponent {
|
||||
|
||||
renderComponent = ({ match }) => {
|
||||
const {
|
||||
@@ -74,3 +63,17 @@ export default class WrappedRoute extends React.PureComponent {
|
||||
return <Route {...rest} render={this.renderComponent} />
|
||||
}
|
||||
}
|
||||
|
||||
WrappedRoute.propTypes = {
|
||||
component: PropTypes.func.isRequired,
|
||||
page: PropTypes.func.isRequired,
|
||||
content: PropTypes.node,
|
||||
componentParams: PropTypes.object,
|
||||
publicRoute: PropTypes.bool,
|
||||
}
|
||||
|
||||
WrappedRoute.defaultProps = {
|
||||
componentParams: {},
|
||||
}
|
||||
|
||||
export default WrappedRoute
|
||||
Reference in New Issue
Block a user