Search code examples
javascriptreactjscomputer-science

What is an imperative escape hatch?


I have been reading Dan Abramov's article react as a rendering ui and saw the term "imperative escape hatch".

My question is what is this? Can some one give an example of one and when it would be useful.


Solution

  • The term in Dan Abramov's article might relate to this section of React docs: https://reactjs.org/docs/design-principles.html#escape-hatches.

    In brief, there are cases that declarative approach of React is not applicable, hence you have to apply an imperative solution instead. Using refs in React to control components, e.g. for DOM manipulation, is considered imperative.