File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -123,17 +123,17 @@ export default class Carousel extends Component {
123
123
autobind ( this ) ;
124
124
}
125
125
126
- // eslint-disable-next-line
127
- UNSAFE_componentWillReceiveProps ( newProps ) {
128
- const { currentSlide } = this . state ;
129
- const numChildren = Children . count ( newProps . children ) ;
126
+ static getDerivedStateFromProps ( props , state ) {
127
+ const { currentSlide } = state ;
128
+ const numChildren = Children . count ( props . children ) ;
130
129
131
130
if ( currentSlide >= numChildren ) {
132
131
// The currentSlide index is no longer valid, so move to the last valid index
133
- this . setState ( {
132
+ return {
134
133
currentSlide : numChildren ? numChildren - 1 : 0
135
- } ) ;
134
+ } ;
136
135
}
136
+ return null ;
137
137
}
138
138
139
139
componentDidUpdate ( prevProps , prevState ) {
You can’t perform that action at this time.
0 commit comments