Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

conditional rendering react typescript

type GeneralType = {
  item1?: string;
  item2: number;
 };
 
const GeneralComponent = (props: GeneralType) => {
  if (props.item1) {
    return <ComponentA {...props} />
  } else {
    return <ComponentB {...props} />
  }
}
Source by bloggie.io #
 
PREVIOUS NEXT
Tagged: #conditional #rendering #react #typescript
ADD COMMENT
Topic
Name
2+7 =