I came across this part of code for defining FormWithRedirect as a FC(FunctionComponent):
declare const FormWithRedirect: FC<FormWithRedirectProps>;
export declare type FormWithRedirectProps = FormWithRedirectOwnProps & Omit<FormProps, 'onSubmit' | 'active'>;
export interface FormWithRedirectOwnProps {
defaultValue?: any;
record?: Record;
redirect?: RedirectionSideEffect;
render: (props: Omit<FormViewProps, 'render' | 'setRedirect'>) => React.ReactElement<any, any>;
...
}
And here is how it is used:
const SimpleForm: FC<SimpleFormProps> = (props) => (
<FormWithRedirect {...props} render={(formProps) => <SimpleFormView {...formProps} />} />
);
considering the definition of FC as below:
type FC<P = {}> = FunctionComponent<P>;
interface FunctionComponent<P = {}> {
(props: PropsWithChildren<P>, context?: any): ReactElement | null;
propTypes?: WeakValidationMap<P>;
contextTypes?: ValidationMap<any>;
defaultProps?: Partial<P>;
displayName?: string;
}
I suppose there should be assignment to FormWithRedirect before using it (something like FormWithRedirect = (props) => {....}), however in the code above there is no assignment and no function is assigned to it. How does it work?