File tree Expand file tree Collapse file tree 4 files changed +57
-5
lines changed Expand file tree Collapse file tree 4 files changed +57
-5
lines changed Original file line number Diff line number Diff line change
1
+ import React from 'react'
2
+ import ReactCSSTransitionReplace from '../../src/ReactCSSTransitionReplace.jsx'
3
+
4
+
5
+ class ChangeChildProps extends React . Component {
6
+
7
+ state = {
8
+ text : 'one' ,
9
+ key : 1 ,
10
+ }
11
+
12
+ handleToggleText = ( ) => {
13
+ this . setState ( state => ( {
14
+ text : this . getToggledText ( state ) ,
15
+ } ) )
16
+ }
17
+
18
+ handleAnimate = ( ) => {
19
+ this . setState ( state => ( {
20
+ text : this . getToggledText ( state ) ,
21
+ key : state . key + 1 ,
22
+ } ) )
23
+ }
24
+
25
+ getToggledText ( state ) {
26
+ return state . text === 'one' ? 'two' : 'one'
27
+ }
28
+
29
+ render ( ) {
30
+ return (
31
+ < div style = { { cursor : 'pointer' } } >
32
+ < a onClick = { this . handleAnimate } > Click to animate</ a >
33
+ { ' | ' }
34
+ < a onClick = { this . handleToggleText } > Change child props</ a > < br />
35
+ < br />
36
+ < ReactCSSTransitionReplace { ...this . props } >
37
+ < p key = { this . state . key } >
38
+ { this . state . text }
39
+ </ p >
40
+ </ ReactCSSTransitionReplace >
41
+ </ div >
42
+ )
43
+ }
44
+ }
45
+
46
+ export default ChangeChildProps
Original file line number Diff line number Diff line change @@ -13,10 +13,13 @@ class ContentAddRemove extends React.Component {
13
13
render ( ) {
14
14
const { style = { } } = this . props
15
15
16
- style . cursor = 'pointer'
16
+ const newStyle = {
17
+ ...style ,
18
+ cursor : 'pointer' ,
19
+ }
17
20
18
21
return (
19
- < div style = { style } onClick = { this . handleClick } >
22
+ < div style = { newStyle } onClick = { this . handleClick } >
20
23
< a > Click to { this . state . added ? 'remove' : 'add' } content</ a > < br />
21
24
< br />
22
25
< ReactCSSTransitionReplace { ...this . props } >
Original file line number Diff line number Diff line change @@ -15,10 +15,13 @@ class ContentSwapper extends React.Component {
15
15
const content = React . Children . toArray ( this . props . children )
16
16
const { style = { } } = this . props
17
17
18
- style . cursor = 'pointer'
18
+ const newStyle = {
19
+ ...style ,
20
+ cursor : 'pointer' ,
21
+ }
19
22
20
23
return (
21
- < ReactCSSTransitionReplace { ...this . props } style = { style } onClick = { this . handleClick } >
24
+ < ReactCSSTransitionReplace { ...this . props } style = { newStyle } onClick = { this . handleClick } >
22
25
{ content [ this . state . index ] }
23
26
</ ReactCSSTransitionReplace >
24
27
)
Original file line number Diff line number Diff line change @@ -114,7 +114,7 @@ class Demo extends React.Component {
114
114
115
115
< h3 id = "react-router-v4" > React Router v4</ h3 >
116
116
< p > Animating React-Router v4 transitions is supported. See the < a
117
- href = "https://github.com/marnusw/react-css-transition-replace#cross-fading-two-components "
117
+ href = "https://github.com/marnusw/react-css-transition-replace#react-router-v4 "
118
118
target = "_blank" > example</ a > for details.</ p >
119
119
120
120
< AnimatedRouter />
You can’t perform that action at this time.
0 commit comments