Fork me on GitHub
#reagent
<
2019-06-01
>
jcb14:06:53

Is there a standardised way of (or example of) creating forwardrefs in reagent? or is it a case of passing an atom through components?

lilactown15:06:13

yea, just passing atoms

lilactown15:06:02

the forwardRef stuff is just cruft from classes

lilactown15:06:36

originally, the React devs didn’t think when users used props spread like:

render() {
    return <div {...this.props} />;
  }
that you want to also pass along the ref, since refs were usually passed to class components in order to access class-specific methods. so they made a thing that was separate from props

lilactown15:06:08

however, with functional components and either hooks or ratoms, you usually have no need for refs outside of accessing the DOM so it’s honestly better to have them on props

lilactown15:06:26

it’s part of React’s plan to eventually remove forwardRef and have refs on props again