I have two components in typesciprt. The parent component creates the state and passs the state and setState to the child component and the child component receives this setState.
parent.tsx
function TestParent():JSX.Element {
const [testResult, setResult] = useState<IResult | null>(null)
return (
<TestChild setResult={setResult}/>
)
}
child.tsx
interface IProps {
setResult: Dispatch<SetStateAction<IResult | null>>
}
function TestChild(props: IProps): JSX.Element {
...
}
When I test child.tsx on child.test.tsx, it says setResult is missing:
test('render component correctly', () => {
render(<TestChild/>
...
}
How should I pass the missing setResult attribute to pass the typescript check?