question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when building a react app

See original GitHub issue

First of all, great work guys! I read your medium posts and had to try out the library. 👏 I’m trying to integrate 3d view and ar features in my existing react project. But I’m getting the following error:

index.js:1 SyntaxError: Unexpected token < in JSON at position 0
    at JSON.parse (<anonymous>)
    at GLTFLoader.parse (GLTFLoader.js:213)
    at Object.onLoad (GLTFLoader.js:145)
    at XMLHttpRequest.<anonymous> (three.module.js:36216)

I’ve made a WebARTest component, then import and render it in App.js. This is how my code looks:

import View3D, { GLTFLoader } from '@egjs/view3d';
import React, { useRef, useEffect } from 'react';
import './viewstyles.css';

const WebARTest = () => {
  const canvasElement = useRef(null);

  useEffect(() => {
    const view3d = new View3D(canvasElement.current);
    const loader = new GLTFLoader();
    loader
      .load('./assets/specstand.glb')
      .then((model) => {
        view3d.display(model);
      })
      .catch((e) => {
        console.error(e);
      });
  }, [canvasElement]);

  return (
    <div id="view3d-wrapper">
      <canvas id="ar-canvas" ref={canvasElement}></canvas>
    </div>
  );
};

export default WebARTest;

I’m following the instruction listed on your tutorial page for loading a model.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
WoodNeckcommented, Jan 16, 2021

@devhims I’m glad to hear that 👍 Don’t worry about filing more issues. I may be slow to respond if I’m working on other things, but I’ll check yours soon as I can 😃

1reaction
WoodNeckcommented, Jan 16, 2021

@devhims Hmm, in that case I assume that file is not loaded as a static file but in the format of a HTML page. Check what it shows on the ./assets/specstand.glb page and if it shows a HTML page, fix the config to serve static files on the assets folder. In other way, moving the 3D model to the public folder will work I think.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create React App not working - Stack Overflow
1. update the npm version (npm install npm@latest -g) · 2. clear the cache (npm cache clean --force) · 3. create the react...
Read more >
How to fix build failures with `create-react-app` in production
The build script bootstrapped by create-react-app performs some validation of your code. When most of this validation fails, create-react-app ...
Read more >
react-scripts fails to build project with Node 17 #11562 - GitHub
Describe the bug we have a CRA app, it used to build with Node 14.x very fine, today I upgrade nodejs to 17.0.0...
Read more >
npx create-react-app not working? Here's the solution.
The current solution is simple — run create-react-app and target the latest version. Run creact-react-app using the latest version. npx create- ...
Read more >
Error Decoder - React
We highly recommend using the development build locally when debugging your app since it tracks additional debug info and provides helpful warnings about ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found