Type Checking
ScandiPWA uses PropTypes to help verify that the expected props are passed, and catch bugs
import { ChildrenType } from 'Type/Common';
export class CategoryPaginationLink extends PureComponent {
static propTypes = {
// component children are treated as props in React
// by leaving out .isRequired, we make them optional
children: ChildrenType,
// we expect the getPage prop to be a function
// it is required, so this will emit a warning if
// getPage is not provided
getPage: PropTypes.func.isRequired,
// isCurrent expects a boolean
isCurrent: PropTypes.bool.isRequired,
// expects a string
url_path: PropTypes.string.isRequired,
// expects a number
pageNumber: PropTypes.number.isRequired
};
static defaultProps = {
// we must provide a default value for every prop that
// is optionalex
children: []
};Advanced Types
Last updated