0

In learning js and react there is talk about state and a mountable component.

What does 'mountable' mean in this context? Every description I have looked at reuses the word 'mount' without explaining it. Assuming we're not talking about horses here and excuse that pun, but what does 'mount' mean for a component. Does it mean 'render' ? does it mean 'present in the DOM for further manipulation' ?

Michael Durrant
  • 93,410
  • 97
  • 333
  • 497
  • 1
    Possible duplicate of [What is "Mounting" in React js?](https://stackoverflow.com/questions/31556450/what-is-mounting-in-react-js) – Lukasstr Jul 27 '17 at 14:23

1 Answers1

1

Mounting is the process of virtualization of a component into the final UI expected.

A browser means outputting a React Element into an actual DOM element (e.g. an HTML ul or p element) in the DOM tree. In a native application that would mean outputting a React element into a native component. You can also write your own renderer and output React components into JSON or XML.

However, the componentDidMount handler is invoked only when rendering to an actual UI representation (DOM or Native Components) but not if you are rendering to an HTML string on the server using renderToString, which makes sense, since the component is not actually mounted until it reaches the browser and executes in it.

The react lifecycles names could be easily changed to render instead of mount, e.g. componentWillRender. That's my hint.

Another more detailed explanations and discussions here: What is "Mounting" in React js?

Yuri Pereira
  • 1,945
  • 17
  • 24