Access child ref from parent component

Hello ya'll. I am having a bit of a brain fart, id like to access the child ref of an element from the parent. What is the best way to do this, ive done this before, but am having a brain fart atm.
6 Replies
DaOfficialWizard🧙
Note - i solved it by using Props and mergeRef from solid primatives
mdynnl
mdynnl•15mo ago
here's the gist of it
const Child = (props) => {
let div;
return <div ref={ref => { div = ref; props.ref(ref) }} />
}
const Parent = () => {
let child;
return <Child ref={child} />
}
const Child = (props) => {
let div;
return <div ref={ref => { div = ref; props.ref(ref) }} />
}
const Parent = () => {
let child;
return <Child ref={child} />
}
DaOfficialWizard🧙
Yeah, that makes a lot of sense 🙂
mdynnl
mdynnl•15mo ago
if you wanna dive a little, try searching signal ref here in discord as i'll be just repeating the same thing over and over again lol
DaOfficialWizard🧙
i tried searching before i asked, but couldnt find anything using my search terms. Thanks for this!
mdynnl
mdynnl•15mo ago
nah, this is only if you want to dive in 😉
Want results from more Discord servers?
Add your server