/* @flow */ 'use strict'; import React, { Component } from 'react'; import { NavLink } from 'react-router-dom'; type State = { style: any; } class Indicator extends Component { state: State; constructor(props: any) { super(props); this.state = { style: { width: 0, left: 0 }, } this.reposition = this.reposition.bind(this); } handleResize() { this.reposition(); } componentDidMount() { this.reposition(); window.addEventListener('resize', this.reposition, false); } componentWillUnmount() { window.removeEventListener('resize', this.reposition, false); } componentDidUpdate(newProps: any) { this.reposition(); } reposition() { const tabs = document.querySelector('.account-tabs'); const active = tabs.querySelector('.active'); const bounds = active.getBoundingClientRect(); const left = bounds.left - tabs.getBoundingClientRect().left; if (this.state.style.left !== left) { this.setState({ style: { width: bounds.width, left: left, } }) } } render() { return (