phenomejs / phenome

The ultimate cross-framework component compiler
http://phenomejs.org
MIT License
71 stars 8 forks source link

React callback refs #38

Closed nolimits4web closed 6 years ago

nolimits4web commented 6 years ago

Looks like string refs in React are highly discouraged and need to be replaces with .createRef or callback refs. Callback ref sounds better to me as at least i can see the way how it can be automaticall converted:

{
  ref: 'el',
},

to

{
  ref: (node) => this.__reactRefs['el'] = node,
}

And adding automatically this.__reactRefs = {} right after super() call in class constructor.

And just replacing this.refs access to this.__reactRefs