未捕获的类型错误:使用 react-bootstrap splitdown 时无法读取未定义的属性“findDOMNode”

0 reactjs react-bootstrap

我使用react-bootstrap 中的示例在我的页面中添加了一个拆分按钮下拉列表以对其进行测试。

我的代码..

<SplitButton bsStyle={"primary"} title={"test"} key={1} id={`this-is-a-test`}>
    <MenuItem eventKey="1">Action</MenuItem>
    <MenuItem eventKey="2">Another action</MenuItem>
    <MenuItem eventKey="3">Something else here</MenuItem>
    <MenuItem divider />
    <MenuItem eventKey="4">Separated link</MenuItem>
</SplitButton>
Run Code Online (Sandbox Code Playgroud)

单击拆分按钮下拉菜单时,控制台显示

未捕获的类型错误:无法读取未定义的属性“findDOMNode”

错误指向 react-bootstrap.js 文件中的代码。

exports.default = function (componentOrElement) {
    return (0, _ownerDocument2.default)(_reactDom2.default.findDOMNode(componentOrElement));
};
Run Code Online (Sandbox Code Playgroud)

我看过其他建议升级 React 和 React-dom 的答案,但我认为我的版本没问题(都是 15.3.0)。

编辑:

它在我创建的导入相同文件的codepen 中工作。问题必须与我的实现有关..

Anu*_*nuj 6

确保您的导入顺序正确!

import ReactDOM from 'react-dom'在导入 React Bootstrap 之前放置