@xgovformbuilder/govuk-react-jsx
Version:
> This package is no longer maintained and will not receive updates bringing it beyond govuk-frontend 4.0.1. If you are using this in your project the simplest way forward is to copy and paste the components from here into your project allowing you to kee
64 lines (54 loc) • 2.01 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["href", "className", "children"];
import _regeneratorRuntime from "@babel/runtime/regenerator";
import React, { useEffect } from 'react';
function SkipLink(props) {
var href = props.href,
className = props.className,
children = props.children,
attributes = _objectWithoutProperties(props, _excluded);
var skipLinkRef = /*#__PURE__*/React.createRef();
useEffect(function () {
_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
var _yield$import, SkipLinkJS;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
if (!(typeof document !== 'undefined')) {
_context.next = 6;
break;
}
_context.next = 3;
return import(
/* webpackChunkName: "govuk-frontend-skip-link" */
/* webpackMode: "lazy" */
/* webpackPrefetch: true */
'govuk-frontend/govuk/components/skip-link/skip-link');
case 3:
_yield$import = _context.sent;
SkipLinkJS = _yield$import["default"];
if (skipLinkRef.current) {
new SkipLinkJS(skipLinkRef.current).init();
}
case 6:
case "end":
return _context.stop();
}
}
}, _callee);
}))();
}, [skipLinkRef]);
return /*#__PURE__*/React.createElement("a", _extends({
href: href,
className: "govuk-skip-link ".concat(className || ''),
"data-module": "govuk-skip-link",
ref: skipLinkRef
}, attributes), children);
}
SkipLink.defaultProps = {
href: '#content'
};
export { SkipLink };