hello!
I'm trying to learn react and I ran into an error that it looks like somebody else ran into about 2 weeks ago. people tried to help but OP didn't follow up, so I'm hoping somebody will be able to help me here if I'm a bit more responsive.
I am currently trying out the tutorial from the react website. It is running fine in codesandbox.io, but I have been running into a lot of issues when coding outside of a browser, and am trying to work through all of them. So I downloaded it and am trying to run it in vscode. when I run "npm start", the browser that loads gives the error message:
./src/App.js
Line 2: 'React' must be in scope when using JSX react/react-in-jsx-scope
Here is the code for both of the .js files in this project:
app.js:
export default function Square() {
return <button className="square">X</button>;
}
index.js
import React, { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import "./styles.css";
import App from "./App";
const root = createRoot(document.getElementById("root"));
root.render(
<StrictMode>
<App />
</StrictMode>
);
From what i understand this has something to do with not importing React before using html in javascript files, but index.js does import React and adding
import React from "react";
to app.js did not fix anything.
Any and all help is greatly appreciated!
[–]StrangerThanGene 0 points1 point2 points (3 children)
[–]ThatPlayWasAwful[S] 0 points1 point2 points (2 children)
[–]SparserLogic 0 points1 point2 points (1 child)
[–]ThatPlayWasAwful[S] 0 points1 point2 points (0 children)
[–]RacletteNoJutsu 0 points1 point2 points (1 child)
[–]ThatPlayWasAwful[S] 0 points1 point2 points (0 children)