1
0
Fork 0
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:
Tim Neutkens 2016-12-29 13:53:20 +01:00 committed by Naoyuki Kanezawa
parent 892da7eb73
commit e8985b3588

View file

@ -1,4 +1,4 @@
import React, { Component, Children } from 'react'
import React, { Component, Children, PropTypes } from 'react'
import Router from './router'
export default class Link extends Component {
@ -7,6 +7,13 @@ export default class Link extends Component {
this.linkClicked = this.linkClicked.bind(this)
}
static propTypes = {
children: PropTypes.oneOfType([
PropTypes.string,
PropTypes.element
]).isRequired
}
linkClicked (e) {
if (e.target.nodeName === 'A' &&
(e.metaKey || e.ctrlKey || e.shiftKey || (e.nativeEvent && e.nativeEvent.which === 2))) {