On the React Router Dom page for V5 (https://v5.reactrouter.com/web/api/NavLink/style-object-func) it states that the style prop will accept a function or an object.
When I try to pass the style function listed in the docs I get the following console error:
Failed prop type: Invalid prop style of type function supplied to NavLink, expected object
I am using version 5.2.1 of React Router Dom, and checking the github page for V5 of React Router, it seems the PropTypes are correctly listed (https://github.com/remix-run/react-router/blob/v5/packages/react-router-dom/modules/NavLink.js)
Here is my code:
<NavLink
to={"/"}
style={isActive => ({
color: isActive ? "green" : "blue"
})}
>
{"hello"}
</NavLink>