bito-code-review[bot] commented on PR #43228:
URL: https://github.com/apache/superset/pull/43228#issuecomment-5304404544

   <!-- Bito Reply -->
   The flagged issue is correct. The current guard `if (!charts[action.key])` 
prevents `ADD_CHART` actions from updating the state because the chart key does 
not exist yet when the action is dispatched. To resolve this, you should check 
if the action type is `ADD_CHART` before applying the guard.
   
   Here is the corrected implementation for 
`superset-frontend/src/components/Chart/chartReducer.ts`:
   
   ```typescript
     if (action.type in actionHandlers) {
       // handlers read the previous chart state, which is gone if the chart was
       // removed while one of its actions was still in flight
       if (action.type !== 'ADD_CHART' && !charts[action.key]) {
         return charts;
       }
       return {
         ...charts,
         [action.key]: actionHandlers[action.type](charts[action.key]),
       };
     }
   ```
   
   There are no other comments on this PR to address.
   
   **superset-frontend/src/components/Chart/chartReducer.ts**
   ```
   if (action.type !== 'ADD_CHART' && !charts[action.key]) {
         return charts;
       }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to