1

I don't remember where, I saw a router using a 404 component like this

<Route component={404}/>

I have tried creating a component

const 404 = props => {
  return (<h1>This is a 404 page!</h1>)
}

And it doesn't even compile. I am using create-react-app and React Router.

carkod
  • 1,507
  • 15
  • 27

2 Answers2

7

No. JavaScript variables cannot begin with numbers.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types

You can name the error component something like Error404

Max
  • 1,407
  • 7
  • 15
4

React is just JavaScript, and variable names cannot begin with or be only numbers. See the link below

What characters are valid for JavaScript variable names?

I would suggest naming it by it's meaning instead, i.e. <NotFound />

Galupuf
  • 2,418
  • 11
  • 24