Im trying to pass a function to a child component, but im getting a number of typescript errors...
parent.tsx
import React from 'react';
import {Child} from './child';
const Parent: React.FC = () => {
function fire() {
console.log('fire')
}
return (
<Child fire={fire}/>
// ^___ error here!
)
}
The error on fire is Type '{ fire: () => void; }' is not assignable to type 'IntrinsicAttributes & { children?: ReactNode; }'.
Property 'fire' does not exist on type 'IntrinsicAttributes & { children?: ReactNode; }'.ts(2322)
child.tsx
import React from 'react';
const Child: React.FC = (props: any) => {
return (
<p onClick={props.fire}>Click Me</p>
)
}
export {Child};