Reputation:
I want to build an app that uses render.props
. I created the component where all my logic is stored:
import React, {useState} from 'react';
function Test(){
let [click, setClick] = useState(0);
function funClick(){
setClick(click++)
}
return(
<div>
{props.render(click, setClick)}
</div>
)
}
export default Test;
The issue is that i've got an error Line 10: 'props' is not defined no-undef
. What means this error and how to solve it?
Upvotes: 1
Views: 115
Reputation: 16576
You need props
as an argument for your component.
import React, {useState} from 'react';
function Test(props) {
let [click, setClick] = useState(0);
function funClick(){
setClick(click++)
}
return(
<div>
{props.render(click, setClick)}
</div>
)
}
export default Test;
Upvotes: 2