Guest User

Untitled

a guest
Nov 14th, 2018
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { h, Component } from 'preact';
  2. import { Router } from 'preact-router';
  3.  
  4. import React from 'react'
  5. import ReactDOM from 'react-dom'
  6.  
  7. import Header from './header';
  8.  
  9. // Code-splitting is automated for routes
  10. import Home from '../routes/home';
  11. import Profile from '../routes/profile';
  12.  
  13.  
  14. if (process.env.NODE_ENV === "development") {
  15.     console.log('node_env:', process.env.NODE_ENV)
  16.     const a11y = require("react-a11y").default;
  17.     a11y(React, ReactDOM, {
  18.         rules: {
  19.             "img-uses-alt": "error",
  20.         }
  21.     });
  22. }
  23.  
  24. export default class App extends Component {
  25.  
  26.     /** Gets fired when the route changes.
  27.      *  @param {Object} event       "change" event from [preact-router](http://git.io/preact-router)
  28.      *  @param {string} event.url   The newly routed URL
  29.      */
  30.     handleRoute = e => {
  31.         this.currentUrl = e.url;
  32.     };
  33.  
  34.  
  35.  
  36.     render() {
  37.         return (
  38.             <div id="app">
  39.                 <img src='foo' />
  40.                 <Header />
  41.                 <Router onChange={this.handleRoute}>
  42.                     <Home path="/" />
  43.                     <Profile path="/profile/" user="me" />
  44.                     <Profile path="/profile/:user" />
  45.                 </Router>
  46.             </div>
  47.         );
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment