大写的 Component 上的未知属性
Unknown prop on Component that is capitalized
我收到以下错误:
warning.js:35 Warning: Unknown prop `notification` on <NotificatonType.InvitedToEventNotification> tag. Remove this prop from the element.
我知道在传输 dom 元素上不标准的道具时会发生这种情况,但是在这里我尝试使用我自己的组件。这是渲染方法:
render() {
const type = this.props.notification.type;
let Tag = "NotificatonType." + type;
return <Tag {...this.props}/>
}
问题是由这一行引起的:
let Tag = "NotificatonType." + type;
您需要传递一个 React 自定义元素,而不是具有 class/function 名称的字符串。这种反应方式看起来像 DIV 或类似的。
您或许可以这样做:
let Tag = NotificationType[type]
但是没有看到你的 NotificationType 代码很难理解。
我收到以下错误:
warning.js:35 Warning: Unknown prop `notification` on <NotificatonType.InvitedToEventNotification> tag. Remove this prop from the element.
我知道在传输 dom 元素上不标准的道具时会发生这种情况,但是在这里我尝试使用我自己的组件。这是渲染方法:
render() {
const type = this.props.notification.type;
let Tag = "NotificatonType." + type;
return <Tag {...this.props}/>
}
问题是由这一行引起的:
let Tag = "NotificatonType." + type;
您需要传递一个 React 自定义元素,而不是具有 class/function 名称的字符串。这种反应方式看起来像 DIV 或类似的。
您或许可以这样做:
let Tag = NotificationType[type]
但是没有看到你的 NotificationType 代码很难理解。