我使用與之反應,路由器側邊欄,現在我想顯示像它在這裏提到的活躍欄圖標:陣營,路由器activeSytle遇到錯誤
https://github.com/reactjs/react-router-tutorial/tree/master/lessons/05-active-links
所以我這樣做:
<li><Link to="/" className="fa fa-bars fa-2x" activeStyle="activeSidebar" aria-hidden="true"></Link></li>
但在控制檯中我得到這個錯誤:
Warning: Unknown prop `activeStyle` on <a> tag. Remove this prop from the element. For details, see
in a (created by Link)
in Link (at index.js:59)
in li (at index.js:59)
in ul (at index.js:58)
in div (at index.js:57)
in div (at index.js:56)
in div (at index.js:55)
in Router (created by BrowserRouter)
in BrowserRouter (at index.js:54)
可能是什麼這是爲什麼?
感謝您的幫助
您可能需要activeClassName,而不是activeStyle – Igor
得到了類似的錯誤:警告:未知的prop'activeClassName'上的標記。 – Felix
您使用的是反應路由器的第4版嗎?你應該使用NavLink這種情況下才能訪問這些屬性(請參閱https://reacttraining.com/react-router/web/api/NavLink) – Igor