alexarsh alexarsh - 5 months ago 1491
React JSX Question

Cannot read property 'getHostNode' of null

I have a horizon/react app with react router and I have a simple button in my app:

<Link className="dark button" to="/">Another Search</Link>

When I click on it, I get the following exception:

Uncaught TypeError: Cannot read property 'getHostNode' of null

The error comes from:

getHostNode: function (internalInstance) {
return internalInstance.getHostNode();

Any idea why am I getting this?


I was facing a similar issue. It turns out that, in my case, was highlighthjs removing comments from the generated dom.

For text, React 15 is adding comment with the reactid instead of a span tag, as in:

<!-- react-text: 248-->
Another Search

Can you try something like this?

<Link className="dark button" to="/"><span>Another Search</span></Link>

This will force the generated DOM to include the span with the proper data-reactid attribute.

I would file an issue with react-router, maybe they can do that internally so you would not have to bother about it. But there are challenges with that as the Link child could be basically anything.