Skip to content

Commit bac81f3

Browse files
lucasgodshalktimdorr
authored andcommitted
Add warning to link.js (#3572)
* Add warning to link.js * Formatting changes. * Move warning in link.js, make invariant. * Update link.js, nit.
1 parent cf79104 commit bac81f3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

modules/Link.js

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react'
22
import warning from './routerWarning'
3+
import invariant from 'invariant'
34
import { routerShape } from './PropTypes'
45

56
const { bool, object, string, func, oneOfType } = React.PropTypes
@@ -73,6 +74,11 @@ const Link = React.createClass({
7374
},
7475

7576
handleClick(event) {
77+
invariant(
78+
this.context.router,
79+
'<Link>s rendered outside of a router context cannot handle clicks.'
80+
)
81+
7682
let allowTransition = true
7783

7884
if (this.props.onClick)

0 commit comments

Comments
 (0)