Skip to content

Commit

Permalink
Fix redirect for version component
Browse files Browse the repository at this point in the history
  • Loading branch information
vallieres13 committed Jan 22, 2024
1 parent 364469f commit f3f1014
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/components/Version.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import React, { useRef } from 'react';
import { Link } from 'react-router-dom';
import { Link, useLocation } from 'react-router-dom';

const Version = () => {

const location = useLocation();
const version = useRef<HTMLDivElement>(null);

const handleClick = () => {
if(location.pathname.startsWith('/article')) {
window.location.href = '/article/open-source-repository';
setTimeout(() => window.location.reload, 0);
}
}

return (
<Link to={'/article/open-source-repository'}>
<Link to={'/article/open-source-repository'} onClick={handleClick}>
<div className="version" ref={version}>
<p>Open-Source Repo <span></span></p>
<div className="lead"></div>
Expand Down
2 changes: 1 addition & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ReactDOM from 'react-dom/client';
import App from './App';

const root = ReactDOM.createRoot(
document.getElementById('app') as HTMLElement
document.getElementById('app') as HTMLElement
);

root.render(<App />);

0 comments on commit f3f1014

Please sign in to comment.