How do I pass input ref values from Child.js to Parent.js in functional component? I have tried using forwardRef but it can only pass one value, what I need is passing multiple input values from Child.js to Parent.js
Child.js
export default function Child() {
const id1 = useRef('')
const id2 = useRef('')
return (
<>
<input type="text" id="id1" ref={id1} />
<label for="id1"> ID 1</label>
<input type="text" id="id2" ref={id2} />
<label for="id2"> ID 2</label>
</>
)
}
Parent.js
export default function Parent() {
function onSubmit() {
console.log(## I WANT REF ID1 AND ID2 FROM CHILD.JS VALUE HERE ##)
}
return ( <>
<Child />
<button onClick={onSubmit}>
Submit
</button>
</>)
}