import { Routes,Route,Navigate } from 'react-router-dom';> }/>
> }/>
> }/>
}/>
> }/>
;Pain point #1 – Navigate missing replace attribute:The AI omitted required `replace` flag causing browser back‑button anomalies.Pain point #2 – History.replace conversion: I ran a global search for `history.replace` after migration and manually changed m to `navigate`.Pain point #3 – withRouter removal: The legacy component still used `this.props.history`. Instead of rewriting whole component to a hook‑based function。I kept it as a class and wrapped it with a custom HOC that injects `navigate`. This conservative approach avoided risky refactors.
The whole router migration took roughly **4 hours**,far less than week I would have spent manually.
Antd 3 使用 Less 全局变量和 `import 'antd/dist/antd.css'`;Antd 5 则基于 @ant-design/cssinjs,不再需要全局 CSS。说起来,删除全局导入后自定义 Less 变量全部失效。
I asked Cursor:“用 Antd 的 ConfigProvider + me 替代原来的 Less变量覆盖,主题色是 #1890ff”。Cursor generated:
import { ConfigProvider } from 'antd';const me = {
说到token。{
colorPrimary: '#1890ff',borderRadius:8,},};
&l t App /& g t;,All components that previously relied on `@primary-color` now read token value via me context.
This upgrade taught me that hardest part of modernizing legacy projects isn’t writing new code—it’s understanding ***** old code was written that way.
AI can rewrite syntax and swap APIs in seconds,but it can’t infer hidden business logic hidden behind a ``withRouter` or a custom lifecycle .
The accelerator is powerful。but you still have to keep both hands on wheel.
参考来源
The model APIs mentioned can be obtained from /gpt108.com . Our production environment has been stable for **12 months**,this article serves purely as a technical case study.