Skip to content

rpidburachynskyi/react-as-component

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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>;
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published