A universal link component for react and react-router, this library encapsulates <a> element from DOM and <NavLink> component from react-router, also it allows you to create any link component from url template.
Link
The basic component is the Link named export, it receives props:
{string} to: The target URL of link.
{boolean} external: Set target="_blank" to <a> element, this also adds rel="noopener noreferrer" prop.
{boolean} refresh: Use simple <a> element instead of react-router’s <Link> component, which will lead a refresh of page when clicked.
{string} activeClassName: The same as react-router’s <NavLink> component, when this prop is provided a non empty value, <NavLink> is used instead of <Link>.
Other props will be passed down to <a> element or <Link> component.
Shortcut
This package also exports two components to fix the external or refresh prop:
react-omni-link
A universal link component for react and react-router, this library encapsulates
<a>element from DOM and<NavLink>component fromreact-router, also it allows you to create any link component from url template.Link
The basic component is the
Linknamed export, it receives props:{string} to: The target URL of link.{boolean} external: Settarget="_blank"to<a>element, this also addsrel="noopener noreferrer"prop.{boolean} refresh: Use simple<a>element instead of react-router’s<Link>component, which will lead a refresh of page when clicked.{string} activeClassName: The same as react-router’s<NavLink>component, when this prop is provided a non empty value,<NavLink>is used instead of<Link>.Other props will be passed down to
<a>element or<Link>component.Shortcut
This package also exports two components to fix the
externalorrefreshprop:Template Link
The
createLinknamed export is a function to create a unversal<Link>component from a url template:The
urlTemplateparameter can be either a string or a template object generated by uri-templates package, the basic usage can be:See uri-templates pacakge for details template syntax.