From 867c232619d3e0d7b53cf00ecc251dde5e186135 Mon Sep 17 00:00:00 2001 From: Bahugunajii Date: Tue, 14 Nov 2023 12:28:52 +0530 Subject: [PATCH] fixed console errors --- app/library/page.tsx | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/app/library/page.tsx b/app/library/page.tsx index 108c40a..7662e48 100644 --- a/app/library/page.tsx +++ b/app/library/page.tsx @@ -1,6 +1,6 @@ "use client" -import React, { useState } from 'react'; +import React, { useState, useEffect } from 'react'; import { useRouter } from 'next/navigation'; import PrimaryButton from '@/components/Button'; import TopBar from '@/components/TopBar'; @@ -17,15 +17,11 @@ const Page: React.FC = () => { setSelectedLibrary(library); }; - if (selectedLibrary === 'NEET Content') { - push(`/library/show?course=${selectedLibrary}`); - return null; - } - - if (selectedLibrary === 'JEE Content') { - push(`/library/show?course=${selectedLibrary}`); - return null; - } + useEffect(() => { + if (selectedLibrary === 'NEET Content' || selectedLibrary === 'JEE Content') { + push(`/library/show?course=${selectedLibrary}`); + } + }, [selectedLibrary, push]); const buttonStyle = 'mx-4 w-40 md:w-64'; const selectedButtonStyle = 'bg-white text-primary font-semibold';