File tree 1 file changed +5
-0
lines changed 1 file changed +5
-0
lines changed Original file line number Diff line number Diff line change 1
1
import React , { Component } from 'react' ;
2
2
import PropTypes from 'prop-types' ;
3
3
import cleanProps from 'clean-react-props' ;
4
+ import uuid from 'uuid/v4' ;
4
5
5
6
class Rotator extends Component {
6
7
constructor ( props ) {
7
8
super ( props ) ;
8
9
9
10
this . state = {
10
11
index : props . index ,
12
+ keyPrefix : `rotator-${ uuid ( ) } ` ,
11
13
} ;
12
14
13
15
this . onIndicatorChange = this . onIndicatorChange . bind ( this ) ;
@@ -88,11 +90,13 @@ class Rotator extends Component {
88
90
89
91
const {
90
92
index,
93
+ keyPrefix,
91
94
} = this . state ;
92
95
93
96
const clonedChildren = React . Children . toArray ( children ) . map ( ( child , childIndex ) => {
94
97
return React . cloneElement ( child , {
95
98
index : childIndex ,
99
+ key : `${ keyPrefix } -child-${ childIndex } ` ,
96
100
position : ( index - childIndex ) * - 1 ,
97
101
onActive : this . onItemActive ,
98
102
onFinish : this . onItemFinish ,
@@ -102,6 +106,7 @@ class Rotator extends Component {
102
106
const clonedIndicator = indicator
103
107
? React . cloneElement ( indicator , {
104
108
index,
109
+ key : `${ keyPrefix } -indicator` ,
105
110
length : children . length ,
106
111
onChange : this . onIndicatorChange ,
107
112
} )
You can’t perform that action at this time.
0 commit comments