Before:
const Input = (props) =>
{
return <input />;
}
class MyInput extends Component
{
componentDidMount()
{
findDOMNode(this.el).focus();
}
render()
{
return <Input ref={el=>this.el=el} />;
}
}
After:
const Input = (props) =>
{
let {refCb, ...others} = props;
if (refCb) {
others.ref = refCb;
}
return <input {...others} />;
}
class MyInput extends Component
{
componentDidMount()
{
this.el.focus();
}
render()
{
return <Input refCb={el=>this.el=el} />;
}
}