I'm trying to wrap my head around how this is coded
const NavLink = ({
to,
exact,
strict,
activeClassName,
className,
activeStyle,
style,
isActive: getIsActive,
...rest
}) => (
<Route
path={typeof to === 'object' ? to.pathname : to}
exact={exact}
strict={strict}
children={({ location, match }) => {
const isActive = !!(getIsActive ? getIsActive(match, location) : match)
return (
<Link
to={to}
className={isActive ? [ activeClassName, className ].join(' ') : className}
style={isActive ? { ...style, ...activeStyle } : style}
{...rest}
/>
)
}}
/>
)
What's going on here? Is this defining a function that returned a JSX element? The only thing that is throwing me is the JSX element being wrapped in parentheses ()
What is going on in the first part where there is isActive: getIsActive?
I was looking at http://es6-features.org/#ExpressionBodies and couldn't find a direct example.
I was trying to figure out how to use the isActive method of router and couldn't parse this code.