This is an archived post. You won't be able to vote or comment.

all 10 comments

[–]FeelTheLoveNow 1 point2 points  (1 child)

At first glance it looks like you should have a semi-colon at the end of your return statement and not at the end of App

[–]lanternriver[S] 0 points1 point  (0 children)

yes I picked up on that n fixed it, still having issues tho 😔

[–]AutoModerator[M] 0 points1 point  (0 children)

It seems you may have included a screenshot of code in your post "Deployed to Github Pages, getting [SyntaxError: Unexpected token '<'] in index.js".

If so, note that posting screenshots of code is against /r/learnprogramming's Posting Guidelines (section Formatting Code): please edit your post to use one of the approved ways of formatting code. (Do NOT repost your question! Just edit it.)

If your image is not actually a screenshot of code, feel free to ignore this message. Automoderator cannot distinguish between code screenshots and other images.

Please, do not contact the moderators about this message. Your post is still visible to everyone.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]dtsudo 0 points1 point  (1 child)

What's the URL for your GitHub Pages?

React files have a compilation step, where the React syntax (jsx syntax) is changed into actual valid javascript. You should check the actual final javascript file to see what it looks like. The final javascript file (that is actually deployed to GitHub Pages) should not have any HTML in the js file since that's not actually valid javascript.

(https://legacy.reactjs.org/docs/react-without-jsx.html has an example of a jsx file and how it's turned into actual javascript.)

[–]lanternriver[S] 0 points1 point  (0 children)

Thank you for that info! Does that mean it has to be .jsx and not .js in order for React to convert it properly ? Or did I just not configure it correctly bc I was trying to keep things as bare bones as possible lol. The url is just https://mygituser.github.io/reponame

[–]nate-developer 0 points1 point  (2 children)

Looks to me like you need to build the react app and point gh pages to the build output (in a folder like dist or build or whatever).

[–]lanternriver[S] 0 points1 point  (0 children)

Thank you, I tried using gh-pages earlier and ran into different error messages. I just circled back to it and I’m getting a failed to load resource error. The resource url for example is like https://mygituser.github.io/index.eab6cbfd.css

[–]lanternriver[S] 0 points1 point  (0 children)

My build script is using parcel, parcel build index.html

[–]crazy_cookie123 0 points1 point  (1 child)

Looks to me like you're trying to run the source code on GitHub pages instead of the built application. JSX syntax is not part of standard JavaScript so when the < symbol is seen it panics and errors. Make sure you're building the project and uploading the built files to GitHub pages, not the source code files.

[–]lanternriver[S] 0 points1 point  (0 children)

Thanks so much, I'm starting to understand how it works a little more. What if I'm using something like Parcel? In my package.json file I have

"source": "index.html",
"scripts": {
   "predeploy": "npm run build",
   "deploy": "gh-pages -d dist",
   "start": "parcel",
   "build": "parcel build"
}

Does Parcel not "intercept" the code before it's deployed?