Reputation: 89
I'm not really sure what I'm screwing up here. I've managed to write my own components in basic A-Frame but since moving to aframe-react I'm getting the error:
Error in ./src/components.js
C:\PATH_TO\src\components.js
1:1 error 'AFRAME' is not defined no-undef
components.js:
AFRAME.registerComponent('pointer_click', {
// ...
});
Am I importing it wrong?
import 'aframe';
import 'aframe-animation-component';
import 'aframe-particle-system-component';
import 'babel-polyfill';
import {Entity, Scene} from 'aframe-react';
import React from 'react';
import ReactDOM from 'react-dom';
import './components.js';
Upvotes: 2
Views: 1796
Reputation: 2389
If you are using create-react-app, then you need to follow this create-react-app-global-vars to reference 'AFRAME' as a global variable.
Basically, include this at the top of your AFrame component file.
const AFRAME = window.AFRAME;
Upvotes: 3
Reputation: 13233
Perhaps that's just a lint error or bundler error? What bundler are you using? I wonder if you have to declare AFRAME
as a global somewhere (e.g., /* globals AFRAME */
at the top) or define AFRAME
as a global in some config.
If you are possibly using semistandard
linter, you can put in package.json:
"semistandard": {
"globals": [
"AFRAME",
"THREE"
],
"ignore": [
"build/**"
]
}
Upvotes: 0