closeModal

closeModal = () => { const maxIndex = this.state.achievements.length - 1; const currentIndex = this.state.activeModalIndex; const lastModalClosed = currentIndex === maxIndex; // set activeModalIndex to an invalid value if we're closing the last modal, say, -1 // otherwise, increment it const newIndex = isLastModal ? -1 : currentIndex + 1; this.setState(previousState => ({ activeModalIndex: newIndex, lastModalClosed, })) }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.