Problem
ImportSpreadsheetConfirmModal fails to compile with React Compiler, because it's not following React best practices, as described in this slack comment:
- Removing manual memoization causes it to break
- bastion components that only return null are a code smell. There are some legitimate uses for these (i.e: you want to conditionally subscribe to some data, you can conditionally render a component, but not conditionally call a hook). But that's the exception to the rule. If we're using a bastion component just for a useEffect, it should probably be a hook
- ImportSpreadsheetConfirmModal is basically monkey-patching the old ConfirmModal pattern with the new global modal pattern under the hood
- Rather than controlling an imperative API (showConfirmModal) via useEffect, it's simpler (and more efficient) to just call it in the user event handler (i.e: button click) that ultimately causes that effect to run. This best practice is documented clearly in the React docs here
Solution
I took a stab at a holistic refactor, covering only one usage. In my opinion it ends up both simpler and more efficient. It does use API.makeRequestWithSideEffects, but this flow doesn't write any data optimistically, and the intention is to wait for a response then show a confirmation modal. Plus this flow is already blocked when offline. So API.makeRequestWithSideEffects is actually the better choice in this case.
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022053928240587573729
- Upwork Job ID: 2053928240587573729
- Last Price Increase: 2026-05-11
Issue Owner
Current Issue Owner: @KJ21-ENG
Problem
ImportSpreadsheetConfirmModal fails to compile with React Compiler, because it's not following React best practices, as described in this slack comment:
Solution
I took a stab at a holistic refactor, covering only one usage. In my opinion it ends up both simpler and more efficient. It does use
API.makeRequestWithSideEffects, but this flow doesn't write any data optimistically, and the intention is to wait for a response then show a confirmation modal. Plus this flow is already blocked when offline. SoAPI.makeRequestWithSideEffectsis actually the better choice in this case.Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @KJ21-ENG