admin管理员组

文章数量:1122846

How can I perform conditional Rendering with Link tag?

Code:

export const CartBottomNavigator: FC<Props> = ({ disabled }) => (
  <BottomNavigator borderStyle="dashed">
    <Button fill disabled={disabled}>
      <Link className={styles.link} href={disabled ? '#' : 'availability'}>
        Select Date
      </Link>
    </Button>
  </BottomNavigator>
);

I don't want the # to show in my URL (e.g. https://localhost:5173/service/location/cart#).

I tried passing href={disabled ? '' : 'availability'}, but my page reloads, and I don't want that either. Any ideas?

本文标签: nextjsConditional rendering with Link tagStack Overflow