I have a main page component in react whose render function looks like this
const MainPage = () => {
return (
<>
<Component1 />
<Component2 />
</>
)
}
And Component has some inputs
const Component1 = () => {
const [val1, setVal1] = React.useState("");
const [val2, setVal2] = React.useState("");
return (
<>
<input type="text" value={val1} onChange={setVal1} />
<input type="text" value={val2} onChange={setVal2} />
</>
)
}
My question is how to get values val1 and val2 in the MainPage component? Thanks in advance