使用react-bootstrap组件报错
在使用react-boostrap的组件的时候结果报了一个错误...
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.
代码大概是这个样子的:
var React = require('React');
var ReactBootstrap = require('react-bootstrap');
var DropdownButton = ReactBootstrap.DropdownButton;
var MenuItem = ReactBootstrap.MenuItem;
var ButtonToolbar = ReactBootstrap.ButtonToolbar;
var Header = React.createClass({
render: function(){
return (
<ButtonToolbar>
<DropdownButton bsStyle="link" title="default">
<MenuItem eventKey="1">active</MenuItem>
<MenuItem divider />
</DropdownButton>
</ButtonToolbar>
);
}
});
module.exports = Header;
请问是为什么呢...
reactjs react-bootstrap bootstrap
炮姐的当麻
9 years, 10 months ago