2
votes

Node v0.12.2

React v0.13.2

Npm v2.7.4

Using the standard typeahead input causes the following error:

Uncaught Error: Invariant Violation: addComponentAsRefTo(...): Only a ReactOwner can have refs. This usually means that you're trying to add a ref to a component that doesn't have an owner (that is, was not created inside of another component's render method). Try rendering this component inside of a new top-level component which will hold the ref.

This is how I am implementing the typeahead...

Index.jsx has:

'use strict'
var React = require('react');
var ReactTypeahead = require('react-typeahead').Typeahead
var QuickSearch = React.createClass({
 render: function () {
  return(
   <ReactTypeahead options={["spam", "foodbar"]}/>
  );
 }
});

var Topbar = React.createClass({
 render: function() {
  return (
   <QuickSearch />
  );
 }
});

module.exports = Topbar;

And then in my App.jsx I have:

'use strict';
var React = require('react');
var Topbar = require('./topbar');
var App = React.createClass({
render: function () {
  return (
   <div>
    <Topbar />
   </div>
  );
 }
});

module.exports = App;
1

1 Answers

0
votes

Seems to me you are missing a semicolon after requiring the typeahead.