score:0

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

import ComponentA from './components/ComponentA';
import ComponentB from './components/ComponentB';
import ComponentC from './components/ComponentC';

export default function Footer() {
  const path = useLocation().pathname;
  const location = path.split('/')[1];

  const checkLocation = (uri) => {
    switch (uri) {
      case 'login':
        return <ComponentA />;
      case 'register':
        return <ComponentB/>;
      case 'about':
        return <ComponentC />;
      default:
        return null;
    }
  };

  return (
    <div>
      {checkLocation(location)}
    </div>
  );
}

Related Query

More Query from same tag