Skip to content

Commit a87418a

Browse files
committed
fixes
1 parent 4072a11 commit a87418a

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

app/routes/MdxRoute.res

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ let default = () => {
289289

290290
let {entries, categories, title} = loaderData
291291

292+
Hooks.useFixAnchor()
293+
292294
<>
293295
{if (pathname :> string) == "/docs/manual/api" {
294296
<>

src/bindings/ReactRouter.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ external useSearchParams: unit => (WebAPI.URLAPI.urlSearchParams, {..} => unit)
1414
external useLoaderData: unit => 'a = "useLoaderData"
1515

1616
/* The types for this are auto-generated from the react-router.config.mjs file */
17-
type path = {pathname: Path.t, search?: string, hash?: string}
17+
type path = {pathname: Path.t, search?: string, hash?: option<string>}
1818

1919
module Loader = {
2020
type loaderArgs = {request: WebAPI.FetchAPI.request}

src/common/Hooks.res

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,15 @@ let useScrollDirection = (~topMargin=80, ~threshold=20) => {
7373
let useFixAnchor = () => {
7474
let {hash, pathname} = ReactRouter.useLocation()
7575
let navigate = ReactRouter.useNavigate()
76-
React.useEffect(() => {
77-
navigate(pathname->Util.String.removeTrailingSlash ++ hash)
78-
None
79-
}, [])
76+
let hash = hash->Option.getOr("")
77+
78+
let target = (pathname :> string)->Util.String.removeTrailingSlash ++ hash
79+
80+
// let _ = navigate(target)
81+
// React.useEffect(() => {
82+
// let _ = navigate(target)
83+
84+
// // None
85+
// None
86+
// }, [])
8087
}

0 commit comments

Comments
 (0)