I have this code below that I tried to convert its syntax (I am using TypeScript, React) from the syntax below to const x = () => {} form.
const EntryDetails: FC<{ entry: Entry }> = ({ entry }) => {
switch (entry.type) {
case 'Hospital':
return <HospitalCard entry={entry} />;
case 'HealthCheck':
return <HealthCheckCard entry={entry} />;
default:
return assertNever(entry);
}
};
Somehow it crashed my code so I assumed I did not convert it properly. Can someone help me get it converted?
My attempt was as below:
const EntryDetails = (entry: Entry) => {
switch (entry.type) {
case 'Hospital':
return <HospitalCard entry={entry} />;
case 'HealthCheck':
return <HealthCheckCard entry={entry} />;
default:
return assertNever(entry);
}
};
and I also tried
const EntryDetails = ({entry}: Entry) => {
switch (entry.type) {
case 'Hospital':
return <HospitalCard entry={entry} />;
case 'HealthCheck':
return <HealthCheckCard entry={entry} />;
default:
return assertNever(entry);
}
};
your function component must look like this...
const EntryDetail: FC<PropsFromYourTypesSheet> = (props) => {
your Code
}