Skip to content

Commit 07bf40f

Browse files
fix(home): add navigate fallback when onNavigate prop not provided
1 parent fdf495e commit 07bf40f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/pages/Home.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// src/pages/Home.jsx
22
import React, { useEffect, useState, useMemo } from 'react';
3+
import { useNavigate } from 'react-router-dom';
34
import { motion } from 'framer-motion';
45
import { Helmet } from 'react-helmet-async';
56
import { Cpu, FlaskConical, BookOpen, ArrowRight } from 'lucide-react';
@@ -12,15 +13,16 @@ import heroVideo from '../../assets/home-intro.mp4';
1213
import heroPoster from '/website-screenshot.png';
1314

1415
const Home = ({ onNavigate }) => {
16+
const navigate = useNavigate();
1517
const featured = [
1618
{ icon: <Cpu size={40} className="text-light-accent dark:text-dark-accent" />, title: 'AI Projects', description: 'Explore our innovative AI solutions and case studies.', link: '/projects' },
1719
{ icon: <FlaskConical size={40} className="text-light-accent dark:text-dark-accent" />, title: 'Cutting-Edge Research', description: 'Read our latest publications and research findings.', link: '/research' },
1820
{ icon: <BookOpen size={40} className="text-light-accent dark:text-dark-accent" />, title: 'AI Books & Cookbooks', description: 'Browse our curated list of essential AI literature.', link: '/books' },
1921
];
2022

2123
const handleNavigation = (e, path) => {
22-
e.preventDefault();
23-
onNavigate(path);
24+
e.preventDefault();
25+
if (onNavigate) onNavigate(path); else navigate(path);
2426
};
2527

2628
// Respect reduced motion: track dynamically & provide memo value

0 commit comments

Comments
 (0)