(nextProps, prevState)
| 86 | } |
| 87 | |
| 88 | static getDerivedStateFromProps(nextProps, prevState) { |
| 89 | let newState = null; |
| 90 | let { activeIndex, direction, indicatorClicked } = prevState; |
| 91 | |
| 92 | if (nextProps.activeIndex !== activeIndex) { |
| 93 | // Calculate the direction to turn |
| 94 | if (nextProps.activeIndex === activeIndex + 1) { |
| 95 | direction = 'end'; |
| 96 | } else if (nextProps.activeIndex === activeIndex - 1) { |
| 97 | direction = 'start'; |
| 98 | } else if (nextProps.activeIndex < activeIndex) { |
| 99 | direction = indicatorClicked ? 'start' : 'end'; |
| 100 | } else if (nextProps.activeIndex !== activeIndex) { |
| 101 | direction = indicatorClicked ? 'end' : 'start'; |
| 102 | } |
| 103 | |
| 104 | newState = { |
| 105 | activeIndex: nextProps.activeIndex, |
| 106 | direction, |
| 107 | indicatorClicked: false, |
| 108 | }; |
| 109 | } |
| 110 | |
| 111 | return newState; |
| 112 | } |
| 113 | |
| 114 | componentDidUpdate(prevProps, prevState) { |
| 115 | if (prevState.activeIndex === this.state.activeIndex) return; |
nothing calls this directly
no outgoing calls
no test coverage detected