Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Expected 0 arguments, but got 1 error. When passing a function as a prop to a child component

$
0
0

I passed the deleteImgfunc function from the insertFarmDiaryDetail component to the InsertFarmDiarySubPage component, which is a child component. The deleteImgfunc function is a function that receives parameters.

So, like my code, even though I created an interface and a value that receives parameters, a red warning line appears in v?.name and this warning message occurs.

Expected 0 arguments, but got 1 error.

enter image description here

How can I get rid of this warning? How do I fix my code?

this is my code

(insertFarmDiaryDetail.tsx)

const insertFarmDiaryDetail = () => {const deleteImgfunc = useCallback((value) => {}, []);return (<InsertFarmDiarySubPage    deleteImgfunc={deleteImgfunc}/>)}

(InsertFarmDiarySubPage.tsx)

interface IProps {    deleteImgfunc?: () => void;}v = {index: 0name: "growthLength 1"size: 22396type: "image/jpeg"uri: "hjk"}const InsertClass44 = forwardRef(({ deleteImgfunc }: IProps, ref: any): JSX.Element => {    return (<Pressable}    onPress={() => deleteImgfunc?.(v?.name)}></Pressable>        );})export default InsertClass44;

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>