feat: add Replay Mode
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
// Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
export function extractReplayIdFromURL() {
|
||||
if (typeof window === "undefined") {
|
||||
return null;
|
||||
}
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
if (urlParams.has("replay")) {
|
||||
return urlParams.get("replay");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { useMemo } from "react";
|
||||
|
||||
import { extractReplayIdFromURL } from "./get-replay-id";
|
||||
|
||||
export function useReplay() {
|
||||
const replayId = useMemo(() => {
|
||||
return extractReplayIdFromURL();
|
||||
}, []);
|
||||
return { isReplay: replayId != null, replayId };
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
export * from "./hooks";
|
||||
Reference in New Issue
Block a user