React's Refs in Reagent (or Om)?

2.2k views Asked by At

I sometimes find it useful to use React's Refs in order to change the state of the DOM as for example to focus an input field after rendering a component. Does Reagent or Om implement this or if not what is the idiomatic way to do this in those libraries?

EDIT (after the discussion below).

The use of this.getDOMNode in componentDidMount is not a generic solution to this problem. It only allows access to the physical DOM element after a component is mounted. Sometimes consistent access to an element is required after every call to render - as for example for triggering events. The way to do that is through Refs.

1

There are 1 answers

0
kliron On BEST ANSWER

I found the answer from the author of Reagent here if anyone cares to look. It turns out refs cannot be directly supported because of the way Reagent does its rendering. The proposed solution is to wrap the portion of a component that needs to be referenced in another component and use component-did-mount in the wrapper.