Are you first timer at lazacode.org? Why not join us and start exchange your programming knowledge with everyone. Register today!

React - add condition with props.source (change class on specific component only)

0 votes
7 views
added 5 days ago in React by lcjr Second Warrant Officer (5,360 points)
edited 3 days ago by lcjr
// navbar.tsx
import SocialShare from '../shared/SocialShare';
return (
  <SocialShare source="navbar" />
)

//SocialShare.tsx
type DropDownContainerProps = {
  source?: string;
};

const DropDownContainer = styled.div<DropDownContainerProps>`
  width: auto;
  margin: 0 auto;
  text-align: center;
  @media (min-width: 992px) {
    display: ${props => (props.source === 'navbar' ? 'none' : 'block')};
  }
`;

type SocialShareProps = {
  source?: string;
};

function SocialShare({ source }: SocialShareProps) {
  return(
   <>
     <DropDownContainer source="navbar">
   </>
  );
}

 

Please log in or register to response this reference.

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...