79117668

Date: 2024-10-23 11:19:55
Score: 1.5
Natty:
Report link

Check you have correctly imported and set up Ziggy in your React component. Beacuse Ziggy provides a route() function. Follow these examples:

  1. Import the Hook:

    import React from 'react'; import { InertiaLink, usePage } from '@inertiajs/inertia-react';

  2. Access the Current Route:

    const { url } = usePage();

  3. Conditionally Render Your Link Component

    const isActive = (path) => url === path;

    return (<InertiaLink href={route('home')} className={isActive('/about') ? 'text-blue' : 'text-green'} >Home);

Reasons:
  • No code block (0.5):
  • Contains question mark (0.5):
  • Low reputation (0.5):
Posted by: Nilesh