chevin99 chevin99 - 1 year ago 260
React JSX Question

How to focus a react-router Link

I have an input box used for searching, and want to be able to press the down key to move focus from the input to the first of a list of

s. It seems what I have here won't work, since
isn't an actual DOM node. I am able to get it to work using
instead of

let Link = require('react-router').Link

let SearchAndSelect = React.createClass({
handleKeyPress: function (e) {
if (e.keyCode === 40) { //'down' key

render: function () {
let ids = ['1', '2' , '3']

return (
<input onKeyDown={this.handleKeyPress} ref="searchBox"/>

{, key) => (
<Link to={`thing/${id}`}

Is there a way to use
with a react-router

Answer Source

If you use ReactDOM.findDOMNode(this.refs['link0']).focus() it should work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download