0

I created a react page (localhost) to follow along with a tutorial, but my webpage is completely blank. The console shows the attached error messageenter image description here

I added

“permissions”: [

"identity",

"YourPage.com"
],

to the manifest.json file which resolved the CORS error, but the first error is still there and my page is still blank!

For the project, I ran npx create-react-app my-app in the terminal to start, then created a components folder in the src folder, where I have an index.jsx file that contains the following code for my accordion menu:

export default function Accordion() {

    const [selected, setSelected] = useState(null);

    return (
    <div className="wrapper">
        <div className="accordion">
            {data && data.length > 0 ? (
                data.map((dataItem) => (
                <div className="item">
                    <div className="title">
                        <h3>{dataItem.question}</h3>
                        <span>+</span>
                    </div>
                </div>))
               ) : (<div>No data found !</div>
            )}
        </div>
    </div>
)}

this code is referencing a data.js file that contains dummy text to go into the accordion menu

then in my app.js file in the src folder, I have the following code:

import './App.css';
import Accordion from './components/accordion';

function App() {
  return (
    <div className="App">
      {/* Accordion Component */}
      <Accordion />
    </div>
  );
}

export default App;

I'm completely self-taught which means I think I'm missing some fundamentals to help me problem solve this, since I am following a tutorial. I already tried this tutorial yesterday and ran into the same problem, so I started over completely today and I don't know what I'm doing wrong. Any help on what I'm missing would be great!

1 Answer 1

0

Have you tried to see if a normal component like a header or text to your App.js would make a valid page, instead of the accordion. Try testing to see if that would work or not first. Also, could you send the error you got as formatted text rather than a image and also add a link to the tutorial you were using just for some additional details.

4
  • 1
    Thank you for the idea! I added <h2>hello world!</h2> to my app.js file but my page is still blank after saving + refreshing
    – dgeary7
    Commented Jun 6 at 19:05
  • Also, the console is showing the following error messages: - Failed to load resource: net::ERR_FILE_NOT_FOUND - Access to internal resource at 'file://C:/Users/dacey/react-projects/public/%PUBLIC_URL%/manifest.json' from origin 'null' has been blocked index.html:1 by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, isolated-app, chrome-extension, chrome, https, chrome-untrusted. the first error is referencing the favicon.ico file, but that's in the public folder - I haven't touched it at all the second error I solved earlier but is back??
    – dgeary7
    Commented Jun 6 at 19:09
  • last thing: here's the tutorial I was following from freeCodeCamp.org youtube.com/watch?v=5ZdHfJVAY-s
    – dgeary7
    Commented Jun 6 at 19:12
  • Are you using npm run start in order to launch your app? Using file:// rather than localhost:3000 could be a source of the CORS error. Also could you send your index.html to see if it might be a URL issue as well? Commented Jun 6 at 19:14

Not the answer you're looking for? Browse other questions tagged or ask your own question.