如何修复使用bootstrap反应的这些浏览器控制台警告?

时间:2016-12-01 12:34:57

标签: react-bootstrap

当我使用bootstrap反应运行我的反应应用程序时,我收到此控制台警告。我相信它们来自我在导航页面中使用的LinkContainer。但我该如何解决这个问题呢?

warning.js:36 Warning: Unknown prop `active` on <a> tag. Remove this prop from the element. 
in a (at index.js:18)
in LinkContainer (created by IndexLinkContainer)
in IndexLinkContainer (at index.js:17)
in NavbarBrand (at index.js:16)
in div (created by NavbarHeader)
in NavbarHeader (at index.js:15)
in div (created by Grid)
in Grid (created by Navbar)
in nav (created by Navbar)
in Navbar (created by Uncontrolled(Navbar))
in Uncontrolled(Navbar) (at index.js:13)
in div (at index.js:12)
in Appnav (created by RouterContext)
in RouterContext (created by Router)
in Router (at index.js:49)

1 个答案:

答案 0 :(得分:0)

您可能知道<a>没有active属性,而您从反应组件传递此信息。

你应该做的是提取所有非有效属性的道具并按你的意愿使用它们

const {active, ...attributes} = this.props;

// do what you need with `active`

return (
    <a {...attributes} />
)