I am trying to do something like that:
interface Props extends RouteComponentProps {
country: 'ONE' | 'OTHER;
}
MyComponent.propTypes = {
country: PropTypes.oneOf(['ONE', 'OTHER']).isRequired,
};
And I am receiving this error:
Type 'Validator<string>' is not assignable to type 'Validator<"ONE" | "OTHER">'.
Type 'string' is not assignable to type '"ONE" | "OTHER"'.ts(2322)
Two doubts:
- How can I type it using PropTypes?
- There is a simpler way to work with both Typescript and PropTypes in a TypeScript Create React APP application?