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🧙
DaOfficialWizard🧙OP•16mo ago
Note - i solved it by using Props and mergeRef from solid primatives
mdynnl
mdynnl•16mo 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🧙
DaOfficialWizard🧙OP•16mo ago
Yeah, that makes a lot of sense 🙂
mdynnl
mdynnl•16mo 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🧙
DaOfficialWizard🧙OP•16mo ago
i tried searching before i asked, but couldnt find anything using my search terms. Thanks for this!
mdynnl
mdynnl•16mo ago
nah, this is only if you want to dive in 😉
Want results from more Discord servers?
Add your server