Why my react app appeared no script tag in the body of the html?

1.1k Views Asked by At

I am working on a react app and I have encountered an error which is when the user logged in, the app will push the user to the dashboard, but the dashboard showed nothing even though it has the h1 tag on the jsx (but other pages work perfectly except dashboard). The html of the dashboard showed "You need to enable JavaScript to run this app." . Anyone can help? Thanks in advance and have a nice day :)

dashboard code:

export class Dashboard extends Component {
  render() {
     return (
      <h1>
        hello
      </h1>
    )
  }
}

dashboard's html:

enter image description here

2

There are 2 best solutions below

0
Mechanic On

For the sake of UX, it renders that to inform users that this website need JavaScript ( they may disabled it manually ) and they shouldn't wait for the website to show up; and/or clears the confusion that the website is not broken ( due to errors or something )

0
Dean James On

If a user who has JavaScript disabled on their browser visits a page, the <noscript> tag is used to display a message to them. Otherwise, it remains hidden. Usually this is used to inform the user the web page requires JavaScript to function. Create React App implements this into the public/index.html file by default.

The noscript documentation from MDN states:

The HTML element defines a section of HTML to be inserted if a script type on the page is unsupported or if scripting is currently turned off in the browser.

You can review all the browsers that support this, however, it is basically supported by all relevant major browsers at the time of writing. IE started support of this from version 11.