Application Android et IOS pour l'amicale des élèves https://play.google.com/store/apps/details?id=fr.amicaleinsat.application
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

preferencesContext.ts 644B

12345678910111213141516171819202122232425
  1. import React, { useContext } from 'react';
  2. import {
  3. defaultPreferences,
  4. PreferenceKeys,
  5. PreferencesType,
  6. } from '../utils/asyncStorage';
  7. export type PreferencesContextType = {
  8. preferences: PreferencesType;
  9. updatePreferences: (
  10. key: PreferenceKeys,
  11. value: number | string | boolean | object | Array<any>
  12. ) => void;
  13. resetPreferences: () => void;
  14. };
  15. export const PreferencesContext = React.createContext<PreferencesContextType>({
  16. preferences: defaultPreferences,
  17. updatePreferences: () => undefined,
  18. resetPreferences: () => undefined,
  19. });
  20. export function usePreferences() {
  21. return useContext(PreferencesContext);
  22. }