     handleSearch: React.PropTypes.func.isRequired
 
   getInitialState: ->
-    queryTerms: @constructQueryTerms(@props.searchQuery)
+    queryTerms = @constructQueryTerms(@props.searchQuery)
+    queryTermIds = (lastQueryTermId++ for term in queryTerms)
+
+    queryTerms: queryTerms
+    queryTermIds: queryTermIds
+
 
   componentWillReceiveProps: (nextProps) ->
     @setState(queryTerms: @constructQueryTerms(nextProps.searchQuery))
-
 
   handleKeyDown: (e) ->
     if e.key is 'Enter'

  handleAddTerm: ->
    queryTerms = @state.queryTerms
    queryTerms.push(createTerm())
    @props.handleQueryChanged(@constructCQPQuery(queryTerms))


  handleRemoveTerm: (termIndex) ->
    queryTerms = @state.queryTerms
    queryTerms.splice(termIndex, 1)
    @props.handleQueryChanged(@constructCQPQuery(queryTerms))



          {queryTerms.map(function(term, index) {
            return (
              <CwbMultiwordTerm
                key={this.state.queryTermIds[index]}
                term={term}
                termIndex={index}
                queryHasSingleTerm={this.state.queryTerms.length === 1}
