var history = this.state.history, pages = this.state.pages, l = history.length, hash = window.location.hash, position = "center"; if (l === 0) { history.push(hash); } else if (hash === history[l - 2]) { history.pop(); position = "left"; } else { history.push(hash); position = "right"; }