useLocation Hooks in react

import React from 'react'
import { useLocation } from 'react-router-dom';

export const Index = () => {
    const location = useLocation();
    console.log(location)
    return (
        <div>
            <h1>This is the {location.pathname} page</h1>
        </div>
    )
}
export default Index;


import React from 'react'
import { useLocation } from 'react-router-dom';

export const Index = () => {
    const location = useLocation();
    console.log(location)
    return (
        <div>
            <h1>This is the {location.pathname.replace("/", '')} page</h1>
        </div>
    )
}
export default Index;

asdf