Bläddra i källkod

add not found

John 8 år sedan
förälder
incheckning
30c8837893

+ 3 - 0
src/routes/NotFound/NotFound.css

@@ -0,0 +1,3 @@
+.notFound {
+
+}

+ 17 - 0
src/routes/NotFound/NotFound.js

@@ -0,0 +1,17 @@
+import React from 'react'
+import { browserHistory } from 'react-router'
+import classes from './NotFound.css'
+
+const goBack = (e) => {
+  e.preventDefault()
+  return browserHistory.goBack()
+}
+
+export const NotFound = () => (
+  <div className={classes.notFound}>
+    <h4>Page not found!</h4>
+    <p><a href='#' onClick={goBack}>&larr; Back</a></p>
+  </div>
+)
+
+export default NotFound

+ 6 - 0
src/routes/NotFound/index.js

@@ -0,0 +1,6 @@
+import NotFound from './NotFound'
+
+export default {
+  path: '*',
+  component: NotFound
+}

+ 2 - 0
src/routes/index.js

@@ -1,6 +1,7 @@
 // We only need to import the modules necessary for initial render
 import Layout from '../components/Layout'
 import Home from './Home'
+import NotFound from './NotFound'
 import CounterRoute from './Counter'
 
 /*  Note: Instead of using JSX, we recommend using react-router
@@ -11,6 +12,7 @@ export const createRoutes = (store) => ({
   component: Layout,
   indexRoute: Home,
   childRoutes: [
+    NotFound,
     CounterRoute(store)
   ]
 })