Skip to content

Commit

Permalink
Move createcontext out of layout
Browse files Browse the repository at this point in the history
  • Loading branch information
Shoreasg committed Sep 3, 2023
1 parent ef12334 commit a58f517
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/components/CarousellBanners.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { InformationCircleIcon } from "@heroicons/react/24/outline";
import Carousel from "nuka-carousel";
import { useContext, useState } from "react";
import { onMenuClickContext } from "../layout";
import { onMenuClickContext } from "../context/MenuContext";

export default function CarousellBanners() {
const [isShownPopUp, setIsShownPopUp] = useState(false);
Expand Down
3 changes: 2 additions & 1 deletion app/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use client";
import { Dispatch, SetStateAction, useContext } from "react"
import { onMenuClickContext } from "../layout";
import { onMenuClickContext } from "../context/MenuContext";


interface HeaderProps {
setMenuClick: Dispatch<SetStateAction<boolean>>;
Expand Down
2 changes: 1 addition & 1 deletion app/components/MobileNavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import Link from "next/link";
import { usePathname } from "next/navigation";
import { useContext } from "react";
import { onMenuClickContext } from "../layout";
import { onMenuClickContext } from "../context/MenuContext";



Expand Down
2 changes: 1 addition & 1 deletion app/components/NavBarV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import Link from "next/link";
import { usePathname } from "next/navigation";
import { Dispatch, SetStateAction, useContext, useState } from "react";
import { onMenuClickContext } from "../layout";
import { onMenuClickContext } from "../context/MenuContext";

interface NavBarProps {
setMenuClick: Dispatch<SetStateAction<boolean>>;
Expand Down
2 changes: 1 addition & 1 deletion app/components/Overlay.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Dispatch, SetStateAction, useContext } from "react";
import { onMenuClickContext } from "../layout";
import { onMenuClickContext } from "../context/MenuContext";

interface overlayProps{
setMenuClick: Dispatch<SetStateAction<boolean>>;
Expand Down
3 changes: 3 additions & 0 deletions app/context/MenuContext.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { createContext } from "react";

export const onMenuClickContext = createContext(true);
4 changes: 2 additions & 2 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
"use client";
import { createContext, useState } from "react";
import { useState } from "react";
import { AnalyticsWrapper } from "./analytics";
import Header from "./components/Header";
import NavBarV2 from "./components/NavBarV2";
import "./globals.css";
import { Plus_Jakarta_Sans, Lato } from "@next/font/google";
import MobileNavBar from "./components/MobileNavBar";
import Overlay from "./components/Overlay";
import { onMenuClickContext } from "./context/MenuContext";

const plusJakartaSans = Plus_Jakarta_Sans({
variable: "--font-jakarta-sans",
Expand All @@ -20,7 +21,6 @@ const lato = Lato({
weight: ["400", "700"],
});

export const onMenuClickContext = createContext(true);

export default function RootLayout({
children,
Expand Down

0 comments on commit a58f517

Please sign in to comment.