Colibri
Colibri

Reputation: 1195

Error in render: "ReferenceError: h is not defined"

All of a sudden I started getting an error from a couple of JSX components. At what point this problem arose, I do not know, so I cannot say what caused it.

It all started when I started getting an error from render(). I fixed it by adding hrender(h).

Then I started getting error from methods in computed. For example, I have code like this:

audioComponent() {
  return(
    <audio autoPlay playsInline ref="audio" />
  )
}

And I'm getting error from it:

Error in render: "ReferenceError: h is not defined"

I use this component in render(h):

<div>
  {this.audioComponent}
</div>

Can you please tell me how to fix this?

Upvotes: 1

Views: 4051

Answers (1)

Matt
Matt

Reputation: 44068

computed functions don't get passed an h (aka createElement), only render does. You can use computed functions to return data but they can't return vdom.

If you want something that simply takes input and returns vdom, consider a functional component instead

Upvotes: 2

Related Questions