Although I love ReactJS, I can say that I sometimes find that interactions that were easy during the pre-ReactJS annoyingly difficult or at least, & # 39 ; indirectly & # 39; goods. A good example is to ensure that a certain
Let's look at a few strategies to focus on
autofocus attribute is honored in ReactJS but only when the
autofocus is easy to use, but only works when the
autofocus attribute is not reliable in all cases.
Because we can not rely solely on the
autofocus attribute, we can use
componentDidUpdate to complete the focus:
class Expressions expands component
componentDidUpdate is activated after the component has been updated, so any change in the parent component would activate this method and your
className on the parent element to indicate that the element is active and thus the
componentDidUpdate will activate.
My perspective on inter-widget interaction is formed by the days of Dojo's thigh UI framework, where each widget usually had a reference to each underlying widget; with ReactJS the practice avoids (hopefully)
ref and the use of
state which is logical, but there is still that part of me that desires a simple reference, that is the reason why the second strategy makes sense for me.