supermedium / aframe-react

:atom: Build virtual reality experiences with A-Frame and React.
https://ngokevin.github.io/aframe-react-boilerplate/
MIT License
1.42k stars 151 forks source link

<Entity> implicitly expects React to be defined #8

Closed RSpace closed 8 years ago

RSpace commented 8 years ago

This code:

import {Entity} from 'aframe-react'
import {Component} from 'react'

class Avatars extends Component {
  render () {
    return (
      <Entity>
      </Entity>
    );
  }
}

results in this error: Uncaught ReferenceError: React is not defined in the line where it tries to render <Entity>. Seems like this component implicitly expects React to be imported be the parent component, as changing line 2 to import React, {Component} from 'react' fixes the problem.

But that shouldn't really be necessary, should it?

ngokevin commented 8 years ago

Yeah, that's weird. I'll check it out once I get back.

RSpace commented 8 years ago

This seems to be a general React issue. This code gives the same ReferenceError:

import {Component} from 'react'

export default class Member extends Component {
  render () {
    return (
      <div className="member-component">
      </div>
    );
  }
}

That is, until React is added to the import statement. So not an issue specific to aframe-react.