Closed sunshineLi2019 closed 3 months ago
推荐在 useEffect 里使用路由跳转,类似 https://reactrouter.com/en/main/hooks/use-navigate
推荐在 useEffect 里使用路由跳转,类似 https://reactrouter.com/en/main/hooks/use-navigate @ClarkXia 我期望知道为什么会出现这个问题呢
搜索那个状态的错误提示 会有 react 一些官方文档说明
Describe the bug
当我在useffect外部使用history进行路由跳转的时候产生了一个错误,警告我有一个不正常的setstate
Expected behavior
期望不会产生这个报错. 我期望了解到为什么会产生这个报错,是因为history还没加载好造成的吗?可是页面仍然可以正常跳转
Actual behavior
我期望前端处理由于localhost:3000/login和localhost:3000/login/造成的差异的时候,在入口layout.tsx处做了判断path的处理代码如下
你可以看到我注释起来的部分,当我将跳转的过程放在useEffect中,这个报错便消失了
Version of ice.js
3.4.8
Content of build.json or ice.config.mts
Additional context
No response