React Refs in Reagent (or Om)?

I sometimes find it useful to use React Refs to change the state of the DOM, for example to focus an input field after a component has rendered. Reagent or Om implements this or if not what is the idiomatic way to do it in these libraries?

EDIT (after discussion below).

Using this.getDOMNode in componentDidMount is not a general solution to this problem. It only allows access to the physical DOM element after the component is installed. Sometimes, sequential access to an element is required after each call for rendering — for example, to trigger events. The way to do this is through Ref.

+3


source to share


1 answer


I found an answer from the author of Reagent here in case anyone needs a look. It turns out that refs cannot be directly maintained due to the way the Reagent renders. The suggested solution is to wrap the part of the component that needs to be referenced in another component and use the wrapped-made component.



+3


source







All Articles