   getInitialState: ->
     textareaHeight: undefined
     initOffsetHeight: undefined
+    value: @props.annotation.value
+
+  componentWillMount: ->
+    @debouncedUpdateAnnotation = _.debounce @updateAnnotation, 500
 
   componentDidMount: ->
     @setState initOffsetHeight: @refs.textInput.offsetHeight

          autoFocus={@props.autoFocus}
          className="standard-input full"
          ref="textInput"
          value={@props.annotation.value}
          onChange={@handleChange}
          rows="1"
          style={height: @state.textareaHeight}

  handleChange: ->
    value = @refs.textInput.value

    if @state.value?.length > value.length
      @setState textareaHeight: @state.initOffsetHeight, =>
        @updateHeight()
    else
      @updateHeight()

    @setState { value }
    @debouncedUpdateAnnotation()

  updateAnnotation: ->
    value = @refs.textInput.value
    newAnnotation = Object.assign @props.annotation, {value}
    @props.onChange newAnnotation
