app:
import React from 'react'
import {Main} from './components/main'
import {Footer} from './components/footer'
import {propType} from './types/types'
const App: React.FC = () => {
const operators:propType[] = [
{id: 1, name: 'str',img: 'str'},
{id: 2, name: 'str', img: 'str'},
{id: 3, name: 'str', img: 'str'}
]
return (<>
<Main {...operators}/>
<Footer/>
</>)
}
export default App;
</>)
}
export default App;
types.tsx
export interface propType {
id:number
name: string
img: string
}
компонент Main в который пытаюсь передать массив данных
import React from 'react'
import {propType} from '../types/types'
export const Main: React.FC<propType[]> = (operators) => (
<div>
{ operators.map(e => <div>{e.id}</div>) }
</div>
)
При передаче не высвечивается не одной ошибки в консоле, на самой странице выводиться только это operators.map is not a function. С одной стороны логично, ведь я из массива преврашаю в объекты, но вот только проблема если я задам operators={operators}, то возникает ошибка.
Сама ошибка:
'{ operators: propType[]; }' is not assignable to type 'IntrinsicAttributes & propType[] & { children?: ReactNode; }'.
Property 'operators' does not exist on type 'IntrinsicAttributes & propType[] & { children?: ReactNode; }'. TS2322