Is it possible to pass a TypeScript type as a prop to a React Component?
export type ActivitiesType = {
RUN: "RUN";
WALK: "REST";
ROUNDS: "ROUNDS";
};
<MyComponent activity={ActivitiesType.RUN} />
Then in MyComponent:
const MyComponent = ({ activity }) => {
if(activity === ActivitiesType.RUN) {
// Do something
}
}
typein activity? Here is more from the official doc