Skip to content

Commit e759fd1

Browse files
authored
Merge pull request #17 from react18-tools/upgrade
Upgrade
2 parents eb249e1 + 4ac0a61 commit e759fd1

File tree

5 files changed

+29
-29
lines changed

5 files changed

+29
-29
lines changed

.changeset/thin-melons-dress.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"nextjs-darkmode": patch
3+
---
4+
5+
Upgrade packages...

examples/nextjs/next-env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/// <reference types="next" />
22
/// <reference types="next/image-types/global" />
3+
/// <reference types="next/navigation-types/compat/navigation" />
34

45
// NOTE: This file should not be edited
56
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

lib/package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,29 @@
1717
],
1818
"exports": {
1919
".": {
20+
"types": "./dist/index.d.ts",
2021
"require": "./dist/index.js",
21-
"import": "./dist/index.mjs",
22-
"types": "./dist/index.d.ts"
22+
"import": "./dist/index.mjs"
2323
},
2424
"./switch": {
25+
"types": "./dist/client/switch/index.d.ts",
2526
"require": "./dist/client/switch/index.js",
26-
"import": "./dist/client/switch/index.mjs",
27-
"types": "./dist/client/switch/index.d.ts"
27+
"import": "./dist/client/switch/index.mjs"
2828
},
2929
"./dist/client/switch": {
30+
"types": "./dist/client/switch/index.d.ts",
3031
"require": "./dist/client/switch/index.js",
31-
"import": "./dist/client/switch/index.mjs",
32-
"types": "./dist/client/switch/index.d.ts"
32+
"import": "./dist/client/switch/index.mjs"
3333
},
3434
"./hooks": {
35+
"types": "./dist/hooks/index.d.ts",
3536
"require": "./dist/hooks/index.js",
36-
"import": "./dist/hooks/index.mjs",
37-
"types": "./dist/hooks/index.d.ts"
37+
"import": "./dist/hooks/index.mjs"
3838
},
3939
"./dist/hooks": {
40+
"types": "./dist/hooks/index.d.ts",
4041
"require": "./dist/hooks/index.js",
41-
"import": "./dist/hooks/index.mjs",
42-
"types": "./dist/hooks/index.d.ts"
42+
"import": "./dist/hooks/index.mjs"
4343
},
4444
"./css": "./dist/index.css",
4545
"./dist/index.css": "./dist/index.css"

lib/src/client/core/core.tsx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { DARK, LIGHT } from "../../constants";
22
import { ColorSchemePreference, ResolvedScheme, useStore } from "../../utils";
3-
import { memo, useEffect } from "react";
3+
import { useEffect } from "react";
44
import { noFOUCScript } from "./no-fouc";
55

66
let media: MediaQueryList,
@@ -14,16 +14,13 @@ interface ScriptProps {
1414
}
1515

1616
/** Avoid rerender of script */
17-
const Script = memo(
18-
({ n, k }: ScriptProps) => (
19-
<script
20-
suppressHydrationWarning
21-
// skipcq: JS-0440
22-
dangerouslySetInnerHTML={{ __html: `(${noFOUCScript.toString()})('${k}')` }}
23-
nonce={n}
24-
/>
25-
),
26-
() => true,
17+
const Script = ({ n, k }: ScriptProps) => (
18+
<script
19+
suppressHydrationWarning
20+
// skipcq: JS-0440
21+
dangerouslySetInnerHTML={{ __html: `(${noFOUCScript.toString()})('${k}')` }}
22+
nonce={n}
23+
/>
2724
);
2825

2926
export interface CoreProps {

lib/src/hooks/use-mode.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,12 @@ export interface UseModeYeild {
1919
* @source - Source code
2020
*/
2121
export const useMode = (): UseModeYeild => {
22-
const [{ m: mode, s: systemMode }, setState] = useStore();
22+
const [{ m, s }, setState] = useStore();
2323
/** Set user preference */
24-
const setMode = (m: ColorSchemePreference) => {
25-
setState(prev => ({ ...prev, m }));
26-
};
2724
return {
28-
mode,
29-
systemMode,
30-
resolvedMode: (mode === SYSTEM ? systemMode : mode) as ResolvedScheme,
31-
setMode,
25+
mode: m,
26+
systemMode: s,
27+
resolvedMode: (m === SYSTEM ? s : m) as ResolvedScheme,
28+
setMode: (m: ColorSchemePreference) => setState({ s, m }),
3229
};
3330
};

0 commit comments

Comments
 (0)