npm.io
1.1.0 • Published 4 years ago

click-should-be-intercepted-for-navigation

Licence
CC0-1.0
Version
1.1.0
Deps
0
Size
2 kB
Vulns
0
Weekly
0
Stars
2

Given a click event, returns true if it's a left-click that you should intercept to trigger pushState navigation.

Taken from React Router's Link component.

const shouldInterceptClick = require('click-should-be-intercepted-for-navigation')

function onClick(event) {
	if (shouldInterceptClick(event)) {
		// do your pushState-based navigation here
	}
}

Keywords