Skip to content

Commit

Permalink
🔨 Ensure preferences context is present (#931)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukevella authored Nov 7, 2023
1 parent 541d7bf commit 3f6a560
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions apps/web/src/contexts/preferences.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { TimeFormat } from "@rallly/database";
import React from "react";
import { useSetState } from "react-use";

import { useRequiredContext } from "@/components/use-required-context";

type Preferences = {
timeZone?: string | null;
locale?: string | null;
Expand All @@ -14,10 +16,9 @@ type PreferencesContextValue = {
updatePreferences: (preferences: Partial<Preferences>) => void;
};

const PreferencesContext = React.createContext<PreferencesContextValue>({
preferences: {},
updatePreferences: () => {},
});
const PreferencesContext = React.createContext<PreferencesContextValue | null>(
null,
);

export const PreferencesProvider = ({
children,
Expand Down Expand Up @@ -46,5 +47,5 @@ export const PreferencesProvider = ({
};

export const usePreferences = () => {
return React.useContext(PreferencesContext);
return useRequiredContext(PreferencesContext);
};

1 comment on commit 3f6a560

@vercel
Copy link

@vercel vercel bot commented on 3f6a560 Nov 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

app – ./

app-rallly.vercel.app
app-git-main-rallly.vercel.app
app.rallly.co

Please sign in to comment.