A
A
ArturPetrov2019-07-26 14:17:33
JavaScript
ArturPetrov, 2019-07-26 14:17:33

Why an error when changing any file in a react project?

in the app.js file I had some specific code:

import React, {Component} from "react";

function App() {
  return (
    <div className="App">
      test
    </div>
  );
}

export default App;

result on the screen:
5d3adda0f1073925493626.png
but when I decided to change in the code to this:
import React, {Component} from "react";
import Homepage from "./components/pages/homePage";

class App extends Component {
    render() {
  return (
    <div className="App">
      <Homepage />
    </div>
  );
        }
}

export default App;

here is such an error:
5d3ade12637d5725669456.png
so that I don’t change, as I didn’t write, the error is always the same only on different lines indicates an error, that is, it’s not at all about some syntax errors in a particular line, I even tried something in the index.js file change then the same error was. Maybe every time I change something in the project, I need to write something on the command line? Something like npm save...?
I also think it may be an error due to the fact that I copied some files (js) from another project to the folder with my project, but this is unlikely, because what's the difference to copy files from another folder or create in a text editor, the name and content will be the same ...
Another moment:
When I write in the App class:
<div className="App">
   какой-то текст
    </div>

works
but when I add tags<div className="App">
<div className="App">
  <h1> </h1>
    </div>

does not work

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
yanis_kondakov, 2019-07-26
@ArturPetrov

You have returnsuch a bracket after it in your HomePage {, but it should be like this (
Well, the corresponding bracket should close

A
Artem Kondratsky, 2019-07-26
@kondrackii

Parentheses are not needed for the class

.... 
class App extends Component {
....

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question