treycordova / nativejsx

JSX to native DOM API transpilation. :yellow_heart: <div> ⟹ document.createElement('div')!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How can I save the dom reference?

j3l11234 opened this issue · comments

As the title
I want to save the reference of some dom.
maybe we can set a callback on the 'ref' prop ? just like react
: )

Referencing a node can be accomplished through querySelector:

const element = (
  <div className="root-node">
    <div className="child"/>
  </div>
);

const child = element.querySelector('.child');
// Or
this.child = element.querySelector('.child');

Will this work for you?

Thanks for adding ref! 🙂