Reputation: 426
When I try to pass props to Component inside the function it always returns "Expected an assignment or function call and instead saw an expression no-unused-expressions".
handleComponent(){
<Component getid={value} />
}
why is this happening and how to correct it?
Upvotes: 0
Views: 103
Reputation: 3488
You used handleComponent
in render function (or in return if you use functional component), I gues, so handleComponent
need to return a piece of JSX code.Your handleComponent
don't have return keyword so it return undefined, that's why you get that error.
Try the following code:
handleComponent(){
return <Component getid={value} />
}
Upvotes: 1
Reputation: 2227
you have to call component in return of render in compoennt like this
render(){
return(
<Component getid={value}/>
)
}
Upvotes: 1