11import * as React from 'react' ;
22import * as ReactDOM from 'react-dom' ;
3- import { UIRouter , UIRouterReact , UIView , UISrefActive , UISref , ReactStateDeclaration , ReactViewDeclaration , trace , pushStateLocationPlugin } from '@uirouter/react' ;
3+ import {
4+ UIRouter ,
5+ UIRouterReact ,
6+ UIView ,
7+ UISrefActive ,
8+ UISref ,
9+ ReactStateDeclaration ,
10+ ReactViewDeclaration ,
11+ trace ,
12+ pushStateLocationPlugin ,
13+ } from '@uirouter/react' ;
414
515import { Child } from './components/Child' ;
616import { Header } from './components/Header' ;
717import { Home } from './components/Home' ;
818import { Nest } from './components/Nest' ;
919
10- let home :ReactStateDeclaration = { name : 'home' , component : Home , url : '/home?foo' } ;
11- let child :ReactStateDeclaration = { name : 'home.child' , component : Child , url : '/child' } ;
12- let nest :ReactStateDeclaration = {
20+ let home : ReactStateDeclaration = {
21+ name : 'home' ,
22+ component : Home ,
23+ url : '/home?foo' ,
24+ } ;
25+ let child : ReactStateDeclaration = {
26+ name : 'home.child' ,
27+ component : Child ,
28+ url : '/child' ,
29+ } ;
30+ let nest : ReactStateDeclaration = {
1331 name : 'home.child.nest' ,
1432 views : {
1533 $default : Nest as ReactViewDeclaration ,
16- " header@home" : Header as ReactViewDeclaration
34+ ' header@home' : Header as ReactViewDeclaration ,
1735 } ,
1836 url : '/nest' ,
19- resolve : [ {
20- token : 'foo' ,
21- resolveFn : ( $transition$ ) => {
22- return new Promise < string > ( ( resolve , reject ) => {
23- setTimeout ( ( ) => {
24- resolve ( 'bar' ) ;
25- } , 1000 ) ;
26- } ) ;
27- }
28- } ]
37+ resolve : [
38+ {
39+ token : 'foo' ,
40+ resolveFn : $transition$ => {
41+ return new Promise < string > ( ( resolve , reject ) => {
42+ setTimeout ( ( ) => {
43+ resolve ( 'bar' ) ;
44+ } , 1000 ) ;
45+ } ) ;
46+ } ,
47+ } ,
48+ ] ,
2949} ;
3050
31-
3251const routerConfig = ( router : UIRouterReact ) => {
33- router . urlRouter . otherwise ( " /home" ) ;
52+ router . urlRouter . otherwise ( ' /home' ) ;
3453 trace . enable ( 1 ) ;
35- }
54+ } ;
3655
37- let el = document . getElementById ( " react-app" ) ;
56+ let el = document . getElementById ( ' react-app' ) ;
3857let app = (
39- < UIRouter plugins = { [ pushStateLocationPlugin ] } states = { [ home , child , nest ] } config = { routerConfig } >
58+ < UIRouter
59+ plugins = { [ pushStateLocationPlugin ] }
60+ states = { [ home , child , nest ] }
61+ config = { routerConfig }
62+ >
4063 < div >
4164 < UISrefActive class = "active" >
42- < UISref to = "home" > < a > Home</ a > </ UISref >
65+ < UISref to = "home" >
66+ < a > Home</ a >
67+ </ UISref >
4368 </ UISrefActive >
44- < UIView render = { ( Comp , props ) => < Comp { ...props } foo = "bar" /> } > < p > Content will load here</ p > </ UIView >
69+ < UIView render = { ( Comp , props ) => < Comp { ...props } foo = "bar" /> } >
70+ < p > Content will load here</ p >
71+ </ UIView >
4572 </ div >
4673 </ UIRouter >
4774) ;
48- ReactDOM . render ( app , el ) ;
75+ ReactDOM . render ( app , el ) ;
0 commit comments