I've got a React-Final-Form which I want it typed with it's own types. But `children(renderRest)' is giving the following error:
Cannot invoke an expression whose type lacks a call signature. Type 'string | number | true | {} | ReactElement ReactElement Component)> | null) | (new (props: any) => Component)> | ReactNodeArray | ReactPortal | ((props: FormRenderProps) => ReactNode)' has no compatible call signatures.ts(2349)
And my code is:
import React from "react";
import styled from "styled-components";
import { Form as StateForm, FormProps } from "react-final-form";
import Box from "src/App/Components/Layout/Box";
const StyledForm = styled(Box)``;
const Form = ({ children, ...rest }: FormProps) => {
return (
<StateForm
{...rest}
render={({ handleSubmit, ...renderRest }) => (
<StyledForm as="form" onSubmit={handleSubmit}>
{children && children(renderRest)}
</StyledForm>
)}
/>
);
};
export default React.memo(Form);
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
This error "Cannot invoke an expression whose type lacks a call signature" has happened in various situations which I was able to solve. But not on this case unfortunately.
Any hints please? Thanks