项目作者: johannesbraeunig

项目描述 :
A simple React component to render a hyperlink or any html element.
高级语言: JavaScript
项目地址: git://github.com/johannesbraeunig/element-or-link.git
创建时间: 2019-10-21T15:13:53Z
项目社区:https://github.com/johannesbraeunig/element-or-link

开源协议:MIT License

下载


element-or-link

A simple React component to render a hyperlink (using react-routers <Link />) or any html element depending on if a to prop is provided.

Example: https://codesandbox.io/s/wizardly-dust-6keed

Dependencies

Usage

yarn add element-or-link

  1. import { ElementOrLink } from 'element-or-link';
  2. const App = () => {
  3. return (
  4. <ElementOrLink to="/my-route">
  5. The element will be a link, not a div.
  6. <ElementOrLink>
  7. )
  8. };

Props

  1. {
  2. to: string,
  3. children: node,
  4. element?: string || node, // default is `span`
  5. displayElement?: boolean, // default is false
  6. }

Example on Codesandbox

https://codesandbox.io/s/wizardly-dust-6keed

🙋‍♂️ Contact me on Twitter

Publish

yarn publish