preventDefault

preventDefault(e) calls e.preventDefault() — drop it straight into an on:* handler. For all stop methods at once use stopEvent. Part of pota/use/event.

Examples

Prevent a link's default

Drops preventDefault straight into an on:click handler so the anchor never navigates.

import { render } from 'pota'
import { preventDefault } from 'pota/use/event'

function App() {
	return (
		<a
			href="https://example.com"
			on:click={preventDefault}
		>
			does not navigate
		</a>
	)
}

render(App)