lasselukkari / aWOT

Arduino web server library.
MIT License
283 stars 41 forks source link

The automatically generated App.js differs from the file in the tutorial #91

Closed ArminPP closed 3 years ago

ArminPP commented 3 years ago

Hello Lasse, I am using your Lib for the first time, everything is going great but I noticed that the automatic generation of the scripts creates a different file than in the tutorial:

automatic generated App.js

import logo from './logo.svg';
import './App.css';

 function App() {              <-------------------------------------------------------------
  return (
    <div className="App">
      <header className="App-header">
        <img src={logo} className="App-logo" alt="logo" />
        <p>
          Edit <code>src/App.js</code> and save to reload.
        </p>
        <a
          className="App-link"
          href="https://reactjs.org"
          target="_blank"
          rel="noopener noreferrer"
        >
          Learn React
        </a>
      </header>
    </div>
  );
}

export default App;

File from the tutorial

import React, { Component } from 'react';      <-------------------------------------------------------------
import logo from './logo.svg';
import './App.css';

class App extends Component {                    <-------------------------------------------------------------
        render() {                                                <-------------------------------------------------------------
    return (
        <div className="App">
        <header className="App-header">
        <img src={logo} className="App-logo" alt="logo" />
        <p>
            Edit <code>src/App.js</code> and save to reload.
        </p>
        <a
            className="App-link"
            href="https://reactjs.org"
            target="_blank"
            rel="noopener noreferrer"
        >
            Learn React
        </a>
    </header>
  </div>
  );
 } 
}

 export default App;

The automatically generated script caused errors, but if I use the script from the tutorial, everything works fine 👍

I am using windows 10 and the following versions: PS J:\esp\eth-test> node -v v14.15.3 PS J:\esp\eth-test> npm -v 6.14.9

Best regards, Armin

lasselukkari commented 3 years ago

Did you see my reply in the issue you created in the tutorial repo. Both styles of react components will work just fine.

I'm closing this one.

lasselukkari commented 3 years ago

Note about the function vs class componentes was added in this commit: https://github.com/lasselukkari/aWOT/commit/f304749780d42b56a0d3611c54883bcbd279a680