Consider a sample component:
enum PET_TYPE { CAT = 'cat', DOG = 'dog', OTHER = 'other',}interface Props { type: PET_TYPE}function Pet(props: Props) { switch (props.type) { case PET_TYPE.CAT: return (<>MEOW!</>); case PET_TYPE.DOG: return (<>WOFF!</>); default: return (<>HELLO</>); }}Pet.PET_TYPE = PET_TYPE;export default Pet;
That will be used like this:
import Pet from "./Pet";<Pet type={Pet.PET_TYPE.CAT} />
Do you think that the addition of PET_TYPE
as an attribute of the component constructor is something that can be done or should it be avoided?