I have the standard arrow map ES7 function with Typescript and React environment:
const getItemList: Function = (groups: any[]): JSX.Element => group.map((item: any, i: number) => { const itemCardElemProps = { handleEvents: () => {}, ...item} return <Item key={`${item.id}_${i}`} {...itemCardElemProps} /> })
and get the error:
TS2739: Type 'Element[]' is missing the following properties from type 'Element': type, props, key
Version: typescript 3.5.3
The React. js error "Type is missing the following properties from type" occurs when we don't pass any props to a component, or don't pass it all of the props it requires. To solve the error, make sure to provide all of the props that are required in the component.
The error "Type is missing the following properties from type" occurs when the type we assign to a variable is missing some of the properties the actual type of the variable expects. To solve the error, make sure to specify all of the required properties on the object.
React. createElement( type, [props], [... children] ) Create and return a new React element of the given type. The type argument can be either a tag name string (such as 'div' or 'span' ), a React component type (a class or a function), or a React fragment type.
The error "JSX element type does not have any construct or call signatures" occurs when we try to pass an element or a react component as props to another component but type the prop incorrectly. To solve the error, use the React. ElementType type.
You could always just send back a single JSX.Element as a fragment, too:
interface IOptions { options: string[] } const CardArray: React.FC<IOptions> = ({ options }) => { return <>{options.map(opt => opt)}</> }
This way you're matching the returned type and it won't affect your markup.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With