62
rated 0 times
[
69]
[
7]
/ answers: 1 / hits: 7858
/ 3 Years ago, wed, february 10, 2021, 12:00:00
I have two component that one passes some func as prop to another and I am not sure what is the proper way to do this without having to receive an eslint error:
Code:
<Parent>
const doSmthHandler = useCallback((id: number)=> {
//do some stuff
},[])
<ComponentB>
doSmth={()=>doSmthHandler(id)} // Here I get eslint warning: JSX props should not use arrow functions eslint warning
</ComponentB>
</Parent>
Component B receives doSmth
prop as function and has a button such as:
<Button onPress={doSmth}>Do stuff</Button>
I wonder how do I pass some argument into the cuntion passed as cb prop into another component that I dont get eslint errors!
More From » reactjs