title: Is it okay to modify some state in Redux if after we modify it we call an action to overwrite the old state?
body: <p>OK, say I have an initial state in our Redux store that looks like this:</p>
  <pre><code>const initialState = {
     userReports: [],
     activeReport: null,
  }
  </code></pre>
  <p>userReports is a list of reports. activeReport is one of those reports (the one that is actively being worked with).</p>
  <p>I want the active report to point to one in the array. In other words, if I modify the active report, it would modify one in the userReports array. This means, the two objects must point to the same memory space. That's easy to set up.</p>
  <p>The alternative to this approach would be to copy one of the reports that is in the userReports array and set it as the active report (now it has a different memory address). The problem is now, when I edit the activeReport, I also have to search through the array of userReports, find the report that resembles the active report and modify it there too. This feels verbose.</p>
  <p><strong>Here is the question:</strong></p>
  <p>Would it be bad practice to have the activeReport point to a report in the array (same object). When I want to change the report I could do something like this (example is using redux thunk):</p>
  <pre><code>export const updateReport = (report) =&gt; async (dispatch, getState) =&gt; {
     try {
        const report = getState().reports.activeReport
        // modify the active report here
        report.title = &quot;blah blah blah&quot;
        dispatch({ type: ACTIONS.UPDATE_REPORT, payload: report })
     } catch (error) {
        console.log(`ERROR: ${error.message}`)
     }
  }
  </code></pre>
  <p>And in my reducer:</p>
  <pre><code>case ACTIONS.UPDATE_REPORT:
       return { ...state, activeReport: action.payload }
  </code></pre>
  <p>as you can see, after updating the report I still return a &quot;new version&quot; of that report and set it as active, but this approach also updates the report in the userReports array because they point to the same memory address.</p>