React - NotFoundError: DOM Exception 8


I’m having some trouble with React and a conditional element. This is my render method:

render() {

 var showLoading=null;

 if(this.state.loadingMessages) {
    showLoading = <div className="loading"><img src="/img/loading.svg"/></div>;

return (
      <h1>Some title</code>
      <div id="messages"></div>


I get the following error because of the showLoading element:

NotFoundError: DOM Exception 8: An attempt was made to reference a Node in a context where it does not exist.

The error appears on Cordova iOS9. Is this an Apple/Safari issue or is it a common React problem? It works if I define

var showLoading = <div className="loading"></div>; 

on the beginning, but why? If I remember right, I have to return an element or null, but null seems not to work.