Here is the structure of my folder:
src--|
|--ComponentsFolder1--Button.tsx
|--ComponentsFolder2--ParentDiv.tsx
My problem is as follows: Button.tsx is a react component which calls a fetch function located in react ParentDiv.tsx with a few parameters:
type getNewVerseProps = {
getNewVerseFunc: (event: React.MouseEvent<HTMLDivElement>) => string;
};
const Button = ({ getNewVerseFunc }: getNewVerseProps) => {
return (
<div>
<div
onClick={getNewVerseFunc.bind(name, id)}>
</div>
</div>
Now, as you can see, I want to call the function on my ParentDiv.tsx file with the specified parameters in Button.tsx:
const getNewVerseFunc = async (name: string, id: string) => {
const requ = await fetch(
`https://api.scripture.api.bible/${name}/${id}`,
{
method: "GET",
headers: {
"api-key": bibleApi,
},
}
};
<Button getNewVerseFunc={getNewVerseFunc}/>
My problem is that the params in the function are not being passed down in the Button component when i call the getNewVerseFunc function in the ParentDiv component