File tree 1 file changed +4
-1
lines changed
1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change 4
4
*/
5
5
import * as React from 'react'
6
6
import { useRequestInfo } from './request-info.ts'
7
+ import { useRevalidator } from '@remix-run/react'
7
8
8
9
export const clientHints = {
9
10
theme : {
@@ -77,18 +78,20 @@ export function useHints() {
77
78
* inaccurate value.
78
79
*/
79
80
export function ClientHintCheck ( { nonce } : { nonce : string } ) {
81
+ const { revalidate } = useRevalidator ( )
80
82
React . useEffect ( ( ) => {
81
83
const themeQuery = window . matchMedia ( '(prefers-color-scheme: dark)' )
82
84
function handleThemeChange ( ) {
83
85
document . cookie = `${ clientHints . theme . cookieName } =${
84
86
themeQuery . matches ? 'dark' : 'light'
85
87
} `
88
+ revalidate ( )
86
89
}
87
90
themeQuery . addEventListener ( 'change' , handleThemeChange )
88
91
return ( ) => {
89
92
themeQuery . removeEventListener ( 'change' , handleThemeChange )
90
93
}
91
- } , [ ] )
94
+ } , [ revalidate ] )
92
95
93
96
return (
94
97
< script
You can’t perform that action at this time.
0 commit comments