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,844
  • 19
  • 32

2 Answers2

8

No. JavaScript variables cannot begin with numbers but can contain numbers after the first character.

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

You can name the error component something like Error404

Max
  • 1,517
  • 9
  • 16
5

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,827
  • 1
  • 12
  • 29