未捕获的不变变量:对象作为React子对象无效(找到:带有键{}的对象)。如果要渲染子级集合,请改用数组。
in BreadCrumb (created by Connect(BreadCrumb))
in Connect(BreadCrumb) (at Dashboard.js:607)
in div (at Dashboard.js:606)
in Dashboard (created by Connect(Dashboard))
in Connect(Dashboard) (created by Form(Connect(Dashboard)))
有时我会收到此错误。
错误的屏幕截图:https://screenpresso.com/=hjLdf
BreadCrumb.js中的代码:
class BreadCrumb extends Component {
render() {
const { title, subpath, subpath2 } = this.props;
return (
<h3 className="text-themecolor">{title}</h3>
);
}
}
dashboard.js中的代码:
class Dashboard extends Component {
render() {
var title = "Dashboard", subpath = "Dashboard";
return (
<BreadCrumb title={title} subpath={subpath} />
);
}
}
答案 0 :(得分:0)
这意味着您要为{}
中的对象{title}
做一个简单的修复:
class BreadCrumb extends Component {
render() {
const { title, subpath, subpath2 } = this.props;
return (
<h3 className="text-themecolor">{title + ''}</h3>
);
}
}