Skip to content
This repository was archived by the owner on May 1, 2025. It is now read-only.
This repository was archived by the owner on May 1, 2025. It is now read-only.

Same link clicked again don't redirect again to the ref.  #434

@bastek338

Description

@bastek338

First of all I would like to thank you for this library, good job!

Issue
When i click for the first time on the link, a scroll redirect to the desired place and it works like a charm.
But when i go again to my clicked link and i try to trigger scroll func again which should redirect into desired hash related component - nothing happens.

I know it may be related to the fact that I currently have the same hash in our url path.

Maybe we can create some function which removes hash from the url. This option might be set as false by default.

My current workaround for this problem is:

const location = useLocation();
const history = useHistory();

  useEffect(() => {
	let timer;
	if (location.hash) {
	   timer = setTimeout(() => {
		history.replace(location.pathname);
	   }, 1000);
	}
	return () => {
		clearTimeout(timer);
	};
  }, [location.hash]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions