Legitcode / image

an img tag, with lazy loading
http://legitcode.github.io/image/
47 stars 0 forks source link

Uncaught Error: A valid ReactComponent must be returned. #6

Open ArnoBuschmann opened 8 years ago

ArnoBuschmann commented 8 years ago

Hi :)

When I use your component, I get this error message:

Uncaught Error: A valid ReactComponent must be returned.

Figured, this happens because React is considering the component only valid if its enclosed in div tags. So when changing your code as below, things work properly well.

    return (
      <div>
        <img
          {...this.props}
          style={style}
          src={this.props.src}
          onLoad={this.fadeIn}
        />
      </div>
    )
zackify commented 8 years ago

I made this a while ago, I'll check it out and update it tonight! On Mon, Apr 11, 2016 at 19:36 ArnoBuschmann notifications@github.com wrote:

Hi :)

When I use your component, I get this error message:

Uncaught Error: A valid ReactComponent must be returned.

Figured, this happens because React is considering the component only valid if its enclosed in div tags. So when changing your code as below, things work properly well.

return (
  <div>
    <img
      {...this.props}
      style={style}
      src={this.props.src}
      onLoad={this.fadeIn}
    />
  </div>
)

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/Legitcode/image/issues/6

ArnoBuschmann commented 8 years ago

Yep. It's useful, thanks for creating it.

zackify commented 8 years ago

I don't see this happening at all after testing. Any way you could provide a stack trace or some more code?

zackify commented 8 years ago

I'm going to close this in a couple days if no reply