Skip to content

Instantly share code, notes, and snippets.

Benjamin Grosse bjgrosse

Block or report user

Report or block bjgrosse

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bjgrosse
bjgrosse / useNavigateTo.js
Last active Jan 22, 2020
React Router hook to navigate to a URL from inline event handler
View useNavigateTo.js
import { useCallback } from "react";
import { useHistory } from "react-router-dom";
/**
* Uses history.push to navigate to the specified URL.
*
* @param {string} url
*
* Usage:
* <Button onClick={useNavigateTo("/start")}>Start</Button>
*/
You can’t perform that action at this time.