My goal is to render a component based on the type prop I am passing to the component.
Here is how I am passing the type prop to the component:
export default function SearchListItem({
type,
}) {
And here is my switch case statement:
const notificationComponent = (type) => {
switch (type) {
case type == 1:
return <Text>1</Text>;
case type == 2:
return <Text>2</Text>;
case type === 3:
return <Text>3</Text>;
case type === 4:
return <Text>3</Text>;
default:
return <Text>No project</Text>;
}
};
And here is how I am rendering the component on the page:
<Title>{notificationComponent(type)}</Title>
Here is how I am passing the props in from the parent component:
<ActivityListItem type={3} />
<ActivityListItem type={4} />
Currently, the component is only returning the No project case although I am passing in props that should match the different cases. Any idea what I'm doing wrong?
notificationComponent(type)? You're calling it with no arguments right now.