|
1 |
| -import React, { Component } from 'react' |
| 1 | +import React from 'react' |
2 | 2 | import { render } from 'react-dom'
|
3 | 3 | import ReactCSSTransitionGroup from 'react-addons-css-transition-group'
|
4 | 4 | import { browserHistory, Router, Route, IndexRoute, Link } from 'react-router'
|
5 | 5 | import './app.css'
|
6 | 6 |
|
7 |
| -class App extends Component { |
8 |
| - render() { |
9 |
| - return ( |
10 |
| - <div> |
11 |
| - <ul> |
12 |
| - <li><Link to="/page1">Page 1</Link></li> |
13 |
| - <li><Link to="/page2">Page 2</Link></li> |
14 |
| - </ul> |
15 |
| - |
16 |
| - <ReactCSSTransitionGroup |
17 |
| - component="div" |
18 |
| - transitionName="example" |
19 |
| - transitionEnterTimeout={500} |
20 |
| - transitionLeaveTimeout={500} |
21 |
| - > |
22 |
| - {React.cloneElement(this.props.children, { |
23 |
| - key: this.props.location.pathname |
24 |
| - })} |
25 |
| - </ReactCSSTransitionGroup> |
26 |
| - |
27 |
| - </div> |
28 |
| - ) |
29 |
| - } |
30 |
| -} |
31 |
| - |
32 |
| - |
33 |
| -class Index extends Component { |
34 |
| - render() { |
35 |
| - return ( |
36 |
| - <div className="Image"> |
37 |
| - <h1>Index</h1> |
38 |
| - <p>Animations with React Router are not different than any other animation.</p> |
39 |
| - </div> |
40 |
| - ) |
41 |
| - } |
42 |
| -} |
43 |
| - |
44 |
| -class Page1 extends Component { |
45 |
| - render() { |
46 |
| - return ( |
47 |
| - <div className="Image"> |
48 |
| - <h1>Page 1</h1> |
49 |
| - <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> |
50 |
| - </div> |
51 |
| - ) |
52 |
| - } |
53 |
| -} |
54 |
| - |
55 |
| -class Page2 extends Component { |
56 |
| - render() { |
57 |
| - return ( |
58 |
| - <div className="Image"> |
59 |
| - <h1>Page 2</h1> |
60 |
| - <p>Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> |
61 |
| - </div> |
62 |
| - ) |
63 |
| - } |
64 |
| -} |
| 7 | +const App = ({ children, location }) => ( |
| 8 | + <div> |
| 9 | + <ul> |
| 10 | + <li><Link to="/page1">Page 1</Link></li> |
| 11 | + <li><Link to="/page2">Page 2</Link></li> |
| 12 | + </ul> |
| 13 | + |
| 14 | + <ReactCSSTransitionGroup |
| 15 | + component="div" |
| 16 | + transitionName="example" |
| 17 | + transitionEnterTimeout={500} |
| 18 | + transitionLeaveTimeout={500} |
| 19 | + > |
| 20 | + {React.cloneElement(children, { |
| 21 | + key: location.pathname |
| 22 | + })} |
| 23 | + </ReactCSSTransitionGroup> |
| 24 | + </div> |
| 25 | +) |
| 26 | + |
| 27 | +const Index = () => ( |
| 28 | + <div className="Image"> |
| 29 | + <h1>Index</h1> |
| 30 | + <p>Animations with React Router are not different than any other animation.</p> |
| 31 | + </div> |
| 32 | +) |
| 33 | + |
| 34 | +const Page1 = () => ( |
| 35 | + <div className="Image"> |
| 36 | + <h1>Page 1</h1> |
| 37 | + <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> |
| 38 | + </div> |
| 39 | +) |
| 40 | + |
| 41 | +const Page2 = () => ( |
| 42 | + <div className="Image"> |
| 43 | + <h1>Page 2</h1> |
| 44 | + <p>Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> |
| 45 | + </div> |
| 46 | +) |
65 | 47 |
|
66 | 48 | render((
|
67 | 49 | <Router history={browserHistory}>
|
|
0 commit comments