mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Add propType check with validation (#2516)
This commit is contained in:
parent
5a0c61a78c
commit
ee29abb8d1
|
@ -1,4 +1,6 @@
|
|||
import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import exact from 'prop-types-exact'
|
||||
import HTTPStatus from 'http-status'
|
||||
import Head from './head'
|
||||
|
||||
|
@ -8,6 +10,10 @@ export default class Error extends React.Component {
|
|||
return { statusCode }
|
||||
}
|
||||
|
||||
static propTypes = exact({
|
||||
statusCode: PropTypes.number
|
||||
})
|
||||
|
||||
render () {
|
||||
const { statusCode } = this.props
|
||||
const title = statusCode === 404
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
import { resolve, format, parse } from 'url'
|
||||
import React, { Component, Children } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import exact from 'prop-types-exact'
|
||||
import Router, { _rewriteUrlForNextExport } from './router'
|
||||
import { warn, execOnce, getLocationOrigin } from './utils'
|
||||
|
||||
|
@ -13,7 +14,8 @@ export default class Link extends Component {
|
|||
this.formatUrls(props)
|
||||
}
|
||||
|
||||
static propTypes = {
|
||||
static propTypes = exact({
|
||||
href: PropTypes.string,
|
||||
prefetch: PropTypes.bool,
|
||||
children: PropTypes.oneOfType([
|
||||
PropTypes.element,
|
||||
|
@ -29,7 +31,7 @@ export default class Link extends Component {
|
|||
]).isRequired,
|
||||
shallow: PropTypes.bool,
|
||||
passHref: PropTypes.bool
|
||||
}
|
||||
})
|
||||
|
||||
componentWillReceiveProps (nextProps) {
|
||||
this.formatUrls(nextProps)
|
||||
|
|
|
@ -83,6 +83,7 @@
|
|||
"path-match": "1.2.4",
|
||||
"pkg-up": "2.0.0",
|
||||
"prop-types": "15.5.10",
|
||||
"prop-types-exact": "^1.1.1",
|
||||
"react-hot-loader": "3.0.0-beta.7",
|
||||
"recursive-copy": "^2.0.6",
|
||||
"send": "^0.15.3",
|
||||
|
|
17
yarn.lock
17
yarn.lock
|
@ -4003,10 +4003,18 @@ object-assign@^4.0.1, object-assign@^4.1.0:
|
|||
version "4.1.1"
|
||||
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
|
||||
|
||||
object-keys@^1.0.8:
|
||||
object-keys@^1.0.10, object-keys@^1.0.8:
|
||||
version "1.0.11"
|
||||
resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d"
|
||||
|
||||
object.assign@^4.0.4:
|
||||
version "4.0.4"
|
||||
resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.0.4.tgz#b1c9cc044ef1b9fe63606fc141abbb32e14730cc"
|
||||
dependencies:
|
||||
define-properties "^1.1.2"
|
||||
function-bind "^1.1.0"
|
||||
object-keys "^1.0.10"
|
||||
|
||||
object.omit@^2.0.0:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/object.omit/-/object.omit-2.0.1.tgz#1a9c744829f39dbb858c76ca3579ae2a54ebd1fa"
|
||||
|
@ -4324,6 +4332,13 @@ promise@^7.0.1, promise@^7.1.1:
|
|||
dependencies:
|
||||
asap "~2.0.3"
|
||||
|
||||
prop-types-exact@^1.1.1:
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/prop-types-exact/-/prop-types-exact-1.1.1.tgz#c2620207e4f77f9762fa1835b0387a464bd08978"
|
||||
dependencies:
|
||||
has "^1.0.1"
|
||||
object.assign "^4.0.4"
|
||||
|
||||
prop-types@15.5.10, prop-types@^15.5.4, prop-types@^15.5.7, prop-types@~15.5.7:
|
||||
version "15.5.10"
|
||||
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.5.10.tgz#2797dfc3126182e3a95e3dfbb2e893ddd7456154"
|
||||
|
|
Loading…
Reference in a new issue