简体   繁体   中英

Are there any obvious reasons my node.js react app is not recognizing any index.html file?

You can see the app here: https://02e7822e.ngrok.io

git repo

My main problem is that index.html somehow never got hooked up, which means

1) the website doesn't scale at all for mobile devices

2) no favicon

Anything obvious I'm missing? I have built websites before but the index.js has always looked a little different every time, so here it is for reference:

import AppBar from '../components/AppBar';
import Block from '../components/Block';
import React from "react";

class Index extends React.Component {
    render() {

        return (
            <div>
                <AppBar/>
                <Block/>
            </div>
        )
    }
}

export default Index;

In previous websites I have been able to use ReactDOM and document.getElementByID to (I think) make some sort of reference to index.html but I tried that and only got syntax errors.

So it looks like you used create-react-app and changed the folder structure all around.... don't do that.

Here is a link to the official folder structure:

https://facebook.github.io/create-react-app/docs/folder-structure

Also. When using a server along with React I have seen a folder structure where the server is kept in the root of the application, and then React is kept in a separate client folder.

my-main-app-folder
my-main-app-folder/
  client/ (This is the folder where React lives)
    public/
      index.html
      favicon.ico
    node_modules/
    src/
      App.js
      index.js
    package.json
    README.md
  .gitignore
  server.js
  package.json
  package-lock.json
  README.md

Something similar to this

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM