使用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;
请问是为什么呢...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
发现问题了...var React = require('react');
改成小写的就行了......
请问你的React-bootstrap的样式这么引用的?