Skip to content

Commit

Permalink
handle client side exceptions when script is not run
Browse files Browse the repository at this point in the history
  • Loading branch information
mayank1513 committed Jun 15, 2024
1 parent 7ddb491 commit 4ceba2c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 62 deletions.
5 changes: 4 additions & 1 deletion lib/src/client/core/core.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,14 @@ const modifyTransition = (themeTransition = "none", nonce = "") => {
* @source - Source code
*/
export const Core = ({ t, nonce, k = "o" }: CoreProps) => {
// handle client side exceptions when script is not run. <- for client side apps like vite or CRA
if (typeof window !== "undefined" && !window.m) s(k);

const [{ m: mode, s: systemMode }, setThemeState] = useStore();

useEffect(() => {
// store global functions to local variables to avoid any interference
[media, updateDOM] = [window.m, window.u];
[media, updateDOM] = [m, u];
/** Updating media: prefers-color-scheme*/
media.addEventListener("change", () =>
setThemeState(state => ({ ...state, s: media.matches ? DARK : LIGHT }) as Store),
Expand Down
61 changes: 0 additions & 61 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4ceba2c

Please sign in to comment.