Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

in nav link if I click on the same active link, page has to refresh in react js

import { useNavigate } from "react-router-dom";

export default function yourIndexPage({yourprops}) {
    let navigate = useNavigate();

    function changeLocation(placeToGo){
        navigate(placeToGo, { replace: true });
        window.location.reload();
    }

    return(
        <ul className='menu'>
            <li className="navbar-item">
                <Link to="/inventory" onClick={() => changeLocation('/inventory')} className="nav-link">Complete Inventory</Link>
            </li>
            <li className="navbar-item">
                <Link to="/inventory/clusters" onClick={() => changeLocation('/inventory/clusters')} className="nav-link">Inventory based on cluster</Link>
            </li>
            <li className="navbar-item">
                <Link to="/inventory/clusters/servertype" onClick={() => changeLocation('/inventory/clusters/servertype')} className="nav-link">Inventory based on cluster and server type</Link>
            </li>
        </ul>
    )

}
Comment

PREVIOUS NEXT
Code Example
Javascript :: Remove # id From URL When Clicked On Href Link 
Javascript :: Turn Module Into Non Module 
Javascript :: ENOENT electron 
Javascript :: javascript get next month name 
Javascript :: bullet mechanism in phaser 
Javascript :: phaser remove collider on stop 
Javascript :: switching light bulbs problem javascript 
Javascript :: generate package json for existing project 
Javascript :: javascript cookies all together 
Javascript :: Staircase 
Javascript :: underscore js 
Javascript :: jquery target all the li element using jquery 
Javascript :: Good Example: Focus moved to AJAX content with tabindex="-1" after a delay 
Javascript :: NodeJS Database initialisation 
Javascript :: give call suggestions while clicking on a contact number in next js 
Javascript :: Inside Fetch Is A Request 
Javascript :: Dependency Injection in Node.js 
Javascript :: create object in jquery dynamically 
Javascript :: vue2-datepicker nuxtjs example 
Javascript :: The most obvious example is handling the click event, 
Javascript :: discord.js create a private channel 
Javascript :: Backbone Template Simple Example 
Javascript :: Backbone Collection Example 
Javascript :: data.json 
Javascript :: fs 
Javascript :: window location href 
Javascript :: call bind apply in javascript 
Javascript :: hello world in react 
Javascript :: url enocde in javascript 
Javascript :: how to run react app on apache server 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =