mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Add warning for multiple children in Link (#558)
* Add warning for multiple children in Link * Add space after if * Use proptype validation
This commit is contained in:
parent
892da7eb73
commit
e8985b3588
|
@ -1,4 +1,4 @@
|
||||||
import React, { Component, Children } from 'react'
|
import React, { Component, Children, PropTypes } from 'react'
|
||||||
import Router from './router'
|
import Router from './router'
|
||||||
|
|
||||||
export default class Link extends Component {
|
export default class Link extends Component {
|
||||||
|
@ -7,6 +7,13 @@ export default class Link extends Component {
|
||||||
this.linkClicked = this.linkClicked.bind(this)
|
this.linkClicked = this.linkClicked.bind(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
children: PropTypes.oneOfType([
|
||||||
|
PropTypes.string,
|
||||||
|
PropTypes.element
|
||||||
|
]).isRequired
|
||||||
|
}
|
||||||
|
|
||||||
linkClicked (e) {
|
linkClicked (e) {
|
||||||
if (e.target.nodeName === 'A' &&
|
if (e.target.nodeName === 'A' &&
|
||||||
(e.metaKey || e.ctrlKey || e.shiftKey || (e.nativeEvent && e.nativeEvent.which === 2))) {
|
(e.metaKey || e.ctrlKey || e.shiftKey || (e.nativeEvent && e.nativeEvent.which === 2))) {
|
||||||
|
|
Loading…
Reference in a new issue