   getInitialState: ->
     page: 1
     pageCount: NaN
-
-  render: ->
+    subjects: null
+
+  componentWillReceiveProps: (nextProps) ->
+    if @props.subjectSet.id isnt nextProps.subjectSet.id
+      @setSubjectResources(nextProps.subjectSet.id, "1")
+      
+  componentWillMount: ->
+    @setSubjectResources(@props.subjectSet.id, @state.page)
+
+  setSubjectResources: (subjetSetId, page) ->
     gettingSetMemberSubjects = apiClient.type('set_member_subjects').get
-      subject_set_id: @props.subjectSet.id
-      page: @state.page
+      subject_set_id: subjetSetId
+      page: page
 
     gettingSetMemberSubjects.then ([setMemberSubject]) =>
       newPageCount = setMemberSubject?.getMeta().page_count

        @setState pageCount: newPageCount

    gettingSubjects = gettingSetMemberSubjects.get 'subject'

    <div>
      <PromiseRenderer promise={gettingSubjects} then={(subjects) =>
        <SubjectSetListingTable subjects={subjects} onPreview={@previewSubject} onRemove={@removeSubject} />
      } />
      <nav className="pagination">
        Page <select value={@state.page} disabled={@state.pageCount < 2 or isNaN @state.pageCount} onChange={(e) => @setState page: e.target.value}>
          {if isNaN @state.pageCount
            <option>?</option>
          else
            for p in [1..@state.pageCount]
              <option key={p} value={p}>{p}</option>}
        </select> of {@state.pageCount || '?'}
      </nav>
    </div>

  previewSubject: (subject) ->
    alert <div className="content-container subject-preview">

React = require 'react'
AutoSave = require '../../components/auto-save'
handleInputChange = require '../../lib/handle-input-change'
apiClient = require 'panoptes-client/lib/api-client'
ChangeListener = require '../../components/change-listener'
Papa = require 'papaparse'
