Styled-components: Forwarding Ref

Created on 10 Apr 2018  路  1Comment  路  Source: styled-components/styled-components

With React now introducing the ability to use ref forwarding it seems like this would be a wonderful opportunity to update styled-components to use, in certain instances.

An example of this is a component I'm working on where I'm using the styled() HOF. When I try to access the ref of the child component I'm getting the style-component class reference instead. Instead I've had to implement a different solution, using childRef and then consuming that in my child component.

It _seems_ like if we were able to just pass in a ref and styled-components forwarded that on, at least in the instance of using the styled()HOF, it would simplify this problem quite a bit.

Most helpful comment

Luckily we were involved in the RFC itself and we didn鈥檛 have to do anything to support this apart from a little fix which has just been merged and will land soon :) https://github.com/styled-components/styled-components/pull/1658

We鈥檙e now interested though in replacing our existing solution, the innerRef prop entirely with either a new API are manual ref forwarding

>All comments

Luckily we were involved in the RFC itself and we didn鈥檛 have to do anything to support this apart from a little fix which has just been merged and will land soon :) https://github.com/styled-components/styled-components/pull/1658

We鈥檙e now interested though in replacing our existing solution, the innerRef prop entirely with either a new API are manual ref forwarding

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lazopm picture lazopm  路  3Comments

ivan-navarro-75 picture ivan-navarro-75  路  3Comments

georgesboris picture georgesboris  路  3Comments

maciossek picture maciossek  路  3Comments

chabanov picture chabanov  路  3Comments