function NavigationLink({ to, title, exactPath, Icon }) {
const resolved = useResolvedPath(to);
const match = useMatch({
path: resolved.pathname,
end: exactPath,
});
const [active, setActive] = useState(false);
return (
<StyledNavLink linkSelected={match}>
<NavLink
to={to}
style={({ isActive }) =>
isActive ? setActive(true) : setActive(false)
}
>
<Title>{title}</Title>
<SelectedContainerIcon active={active}>
<Icon />
</SelectedContainerIcon>
</NavLink>
</StyledNavLink>
);
}
Right now I am using this, using the "isActive" to change a state that is then passed to the child component (to change the icon's background color) but it is giving me a rendering error (despite actually working well). Is there a way to pass the "isActive" directly to the child?