Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from 'react';
- import {basename} from '@/router';
- import history from '@/history';
- const createOnClickAnchor = (callback) => {
- return (e) => {
- e.preventDefault();
- history.push(e.currentTarget.getAttribute('href'));
- callback(e);
- };
- };
- export default ({href, onClick = () => {}, children, ...rest}) => (
- <a
- href={basename + href}
- onClick={createOnClickAnchor(onClick)}
- {...rest}
- >
- {children}
- </a>
- );
- // This component can be used like:
- //
- // <Link href="/admin" id="admin-link">Go to Admin</Link>
- //
Add Comment
Please, Sign In to add comment