fix context error
This commit is contained in:
@@ -1,29 +1,13 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import "./style.css";
|
import "./style.css";
|
||||||
import { useState, createContext, useContext } from "react";
|
import { useState } from "react";
|
||||||
import { AuthProvider } from "react-oidc-context";
|
import { AuthProvider } from "react-oidc-context";
|
||||||
import { oidcConfig, userManager } from "muzak/config/auth";
|
import { oidcConfig, userManager } from "muzak/config/auth";
|
||||||
import { Source_Sans_3, Nunito } from "next/font/google";
|
import { Source_Sans_3, Nunito } from "next/font/google";
|
||||||
import AuthStatus from "muzak/components/AuthStatus";
|
import AuthStatus from "muzak/components/AuthStatus";
|
||||||
import NavigationBar from "muzak/components/NavigationBar";
|
import NavigationBar from "muzak/components/NavigationBar";
|
||||||
import Quota from "muzak/components/Quota";
|
import Quota from "muzak/components/Quota";
|
||||||
|
import { AnimationContext } from "muzak/contexts/AnimationContext";
|
||||||
interface AnimationContextType {
|
|
||||||
isAnimate: boolean;
|
|
||||||
setIsAnimate: React.Dispatch<React.SetStateAction<boolean>>;
|
|
||||||
}
|
|
||||||
|
|
||||||
const AnimationContext = createContext<AnimationContextType | undefined>(
|
|
||||||
undefined,
|
|
||||||
);
|
|
||||||
|
|
||||||
export const useAnimation = () => {
|
|
||||||
const context = useContext(AnimationContext);
|
|
||||||
if (context === undefined) {
|
|
||||||
throw new Error("useAnimation must be used within an AnimationProvider");
|
|
||||||
}
|
|
||||||
return context;
|
|
||||||
};
|
|
||||||
|
|
||||||
const nunito = Nunito({
|
const nunito = Nunito({
|
||||||
subsets: ["latin"],
|
subsets: ["latin"],
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { Nunito } from "next/font/google";
|
import { Nunito } from "next/font/google";
|
||||||
import { api } from "muzak/data/fetcher";
|
import { api } from "muzak/data/fetcher";
|
||||||
import { useAnimation } from "../layout";
|
import { useAnimation } from "muzak/contexts/AnimationContext";
|
||||||
|
|
||||||
const nunito = Nunito({
|
const nunito = Nunito({
|
||||||
weight: "900",
|
weight: "900",
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
"use client";
|
||||||
|
import { createContext, useContext } from "react";
|
||||||
|
|
||||||
|
interface AnimationContextType {
|
||||||
|
isAnimate: boolean;
|
||||||
|
setIsAnimate: React.Dispatch<React.SetStateAction<boolean>>;
|
||||||
|
}
|
||||||
|
|
||||||
|
const AnimationContext = createContext<AnimationContextType | undefined>(
|
||||||
|
undefined,
|
||||||
|
);
|
||||||
|
|
||||||
|
export const useAnimation = () => {
|
||||||
|
const context = useContext(AnimationContext);
|
||||||
|
if (context === undefined) {
|
||||||
|
throw new Error("useAnimation must be used within an AnimationProvider");
|
||||||
|
}
|
||||||
|
return context;
|
||||||
|
};
|
||||||
|
|
||||||
|
export { AnimationContext };
|
||||||
@@ -9,7 +9,8 @@
|
|||||||
"muzak/config/*": ["./src/config/*"],
|
"muzak/config/*": ["./src/config/*"],
|
||||||
"muzak/data/*": ["./src/data/*"],
|
"muzak/data/*": ["./src/data/*"],
|
||||||
"muzak/app/*": ["./src/app/*"],
|
"muzak/app/*": ["./src/app/*"],
|
||||||
"muzak/components/*": ["./src/components/*"]
|
"muzak/components/*": ["./src/components/*"],
|
||||||
|
"muzak/contexts/*": ["./src/contexts/*"]
|
||||||
},
|
},
|
||||||
|
|
||||||
"allowJs": false,
|
"allowJs": false,
|
||||||
|
|||||||
Reference in New Issue
Block a user