If I have an interface defined for a function component, say
MyFuncComp.tsx
import React from 'react'
interface MyFuncCompProps {
x: string
y: number
z: Array<ComplexType>
}
export function MyFuncComp(props: MyFuncCompProps) {
return <>...</>
}
And I use the component in another component
MyPage.tsx
import React from 'react'
import {MyFuncComp} from 'MyFuncComp.tsx'
export function MyPage(){
const [x, setX] = React.useState()
const [y, setY] = React.useState()
const [z, setZ] = React.useState()
return <><MyFuncComp x={x} y={y} z={z} /></>
}
How can I extract the type of the attributes defined within the function component so that I may use the same type in MyPage.tsx as well?
I understand that I can export/import the interfaces all over, but I want to avoid that.