import React from 'react' const DEFAULT_SIZE = 42 interface BuilderBarProps { placeholder: string; badgeURL: string; host?: string; onChange: (value: string) => void; onFocus: () => void; onBlur: () => void; } export default class BuilderBar extends React.Component { shouldComponentUpdate ({ badgeURL }) { const url = badgeURL ? `#${badgeURL}` : window.location.pathname window.history.replaceState({}, document.title, url) return true } calcInputSize = url => { return url.length < DEFAULT_SIZE ? DEFAULT_SIZE : url.length } handleChange = ev => this.props.onChange(ev.target.value) render () { const { host, placeholder, badgeURL } = this.props const inputSize = this.calcInputSize(badgeURL) return ( ) } }