forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates Error 404 component so that we can set 404 status on SSR rend…
…ers (mui#357)
- Loading branch information
Showing
1 changed file
with
22 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,26 @@ | ||
import React from 'react'; | ||
import React, { Component, PropTypes } from 'react'; | ||
|
||
function Error404() { | ||
return ( | ||
<div>Sorry, that page was not found.</div> | ||
); | ||
class Error404 extends Component { | ||
componentWillMount() { | ||
const { staticContext } = this.context.router; | ||
if (staticContext) { | ||
staticContext.missed = true; | ||
} | ||
} | ||
|
||
render() { | ||
return ( | ||
<div> | ||
<div>Sorry, that page was not found.</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
Error404.contextTypes = { | ||
router: PropTypes.shape({ | ||
staticContext: PropTypes.object, | ||
}).isRequired, | ||
}; | ||
|
||
export default Error404; |