UNPKG

@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

39 lines (33 loc) 1.11 kB
import _extends from "@babel/runtime/helpers/extends"; import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; var _excluded = ["children", "to", "href", "forwardedRef"]; import React from 'react'; import { Link as ReactRouterLink } from 'react-router-dom'; function Link(props) { var children = props.children, to = props.to, href = props.href, forwardedRef = props.forwardedRef, attributes = _objectWithoutProperties(props, _excluded); if (to) { return /*#__PURE__*/React.createElement(ReactRouterLink, _extends({ innerRef: forwardedRef, to: to }, attributes), children); } return /*#__PURE__*/React.createElement("a", _extends({ ref: forwardedRef, href: href || '#' }, attributes), children); } Link.defaultProps = { forwardedRef: null }; function forwardRef(props, ref) { return /*#__PURE__*/React.createElement(Link, _extends({}, props, { forwardedRef: ref })); } forwardRef.displayName = 'LinkWithRef'; var LinkWithRef = /*#__PURE__*/React.forwardRef(forwardRef); export { LinkWithRef as Link };