Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

react-as-component

kitsorik23ISC1.0.7

Create a component with custom selector

react, component

readme

How to install

npm i react-as-component

How to use

import AsComponent from 'react-as-component';

function MyDivFromAsComponent (){
  return <AsComponent as={"div"}>...</AsComponent>;
}

Examples

Example button, which can be link

import AsComponent from 'react-as-component';

function MyButton({ asLink = false,  value = "" }) {
  return <AsComponent as={asLink ? 'a' : 'button'}>{value}</AsComponent>;
}

or Link from react-router-dom

import { Link } from 'react-router-dom';
import AsComponent from 'react-as-component';

function MyButton({ asLink = false, value = "" }) {
  return <AsComponent as={asLink ? Link : 'button'}>{value}</AsComponent>;
}