-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Provide an API for checking more specific components via Props and/or State.
For example:
let maybeFC: React.FC<{foo: string}> | string = ({foo}) => <div>{`${foo}, I'm a function component!`}</div>;
if (Math.random() > 0.5) {
maybeFC = 'Not FC';
}
if (isFunctionComponent<{foo: string}>(maybeFC)) {
const fcWithProps: React.FC<{foo: string}> = maybeFC;
const FCWithProps = fcWithProps;
const fcWithPropsElem = <FCWithProps foo='bar'}/>; // should not have a type error
} else {
const notFC: string = maybeFC;
}
Metadata
Metadata
Assignees
Labels
No labels