Skip to content

Commit e4d743f

Browse files
committed
lint checks fixed
1 parent 4ee28d9 commit e4d743f

2 files changed

Lines changed: 26 additions & 18 deletions

File tree

packages/docusaurus-theme-openapi-docs/src/theme/ApiItem/hooks.ts

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,38 @@
55
* LICENSE file in the root directory of this source tree.
66
* ========================================================================== */
77

8-
import { TypedUseSelectorHook, useDispatch, useSelector } from "react-redux";
98
import ExecutionEnvironment from "@docusaurus/ExecutionEnvironment";
9+
import { TypedUseSelectorHook, useDispatch, useSelector } from "react-redux";
1010

1111
import type { RootState, AppDispatch } from "./store";
1212

13+
const defaultState: RootState = {
14+
accept: { value: undefined },
15+
contentType: { value: undefined },
16+
response: { value: undefined },
17+
server: { value: undefined, options: [] },
18+
body: { type: "empty" },
19+
params: {},
20+
auth: { selected: undefined, options: {}, data: {} },
21+
} as RootState;
22+
1323
export const useTypedDispatch = (): any => {
24+
const dispatch = useDispatch<AppDispatch>();
25+
1426
if (!ExecutionEnvironment.canUseDOM) {
1527
return () => {}; // Return a no-op function during SSR
1628
}
17-
return useDispatch<AppDispatch>();
29+
return dispatch;
1830
};
1931

2032
export const useTypedSelector: TypedUseSelectorHook<RootState> = (selector) => {
21-
if (!ExecutionEnvironment.canUseDOM) {
22-
// Return default values during SSR to prevent null store access
23-
return selector({
24-
accept: { value: undefined },
25-
contentType: { value: undefined },
26-
response: { value: undefined },
27-
server: { value: undefined, options: [] },
28-
body: { type: "empty" },
29-
params: {},
30-
auth: { selected: undefined, options: {}, data: {} },
31-
} as RootState);
32-
}
33-
return useSelector(selector);
33+
const result = useSelector((state: RootState) => {
34+
if (!ExecutionEnvironment.canUseDOM) {
35+
// Return default values during SSR to prevent null store access
36+
return selector(defaultState);
37+
}
38+
return selector(state);
39+
});
40+
41+
return result;
3442
};

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5492,9 +5492,9 @@ caniuse-api@^3.0.0:
54925492
lodash.uniq "^4.5.0"
54935493

54945494
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001578, caniuse-lite@^1.0.30001587:
5495-
version "1.0.30001588"
5496-
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001588.tgz#07f16b65a7f95dba82377096923947fb25bce6e3"
5497-
integrity sha512-+hVY9jE44uKLkH0SrUTqxjxqNTOWHsbnQDIKjwkZ3lNTzUUVdBLBGXtj/q5Mp5u98r3droaZAewQuEDzjQdZlQ==
5495+
version "1.0.30001731"
5496+
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001731.tgz"
5497+
integrity sha512-lDdp2/wrOmTRWuoB5DpfNkC0rJDU8DqRa6nYL6HK6sytw70QMopt/NIc/9SM7ylItlBWfACXk0tEn37UWM/+mg==
54985498

54995499
caseless@~0.12.0:
55005500
version "0.12.0"

0 commit comments

Comments
 (0)