replace
本页内容

replace

摘要

参考文档 ↗

一个重定向 Response,它将执行 history.replaceState 而不是 history.pushState 来进行客户端导航重定向。它会设置状态码和 Location 响应头。默认为 302 Found

import { replace } from "react-router";

export async function loader() {
  return replace("/new-location");
}

参数

url

要重定向到的 URL。

init

要包含在响应中的状态码或 ResponseInit 对象。

返回

一个包含重定向状态和 Location 标头的 Response 对象。

文档和示例 CC 4.0
编辑