File size: 587 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { Link as RouterLink, LinkProps as RouterLinkProps } from 'react-router-dom';
import { useSubscriptionManagerContext } from '../subscription-manager-context';

type LinkProps = Omit< RouterLinkProps, 'to' > &
	Omit< React.HTMLProps< HTMLAnchorElement >, 'ref' > & { active?: boolean };

const Link = ( { active = false, ...props }: LinkProps ) => {
	const { isSubscriptionsPortal } = useSubscriptionManagerContext();

	if ( active || isSubscriptionsPortal ) {
		return <RouterLink to={ props.href || '' } { ...props } />;
	}
	return <a { ...props }></a>;
};

export default Link;