React Render As
This library lets you easily create components which take an as
prop to change which component they should render as
Installation
npm i --save react-render-as
Usage
Creating simple components
import renderAs from 'react-render-as'; const SomeComponent = name <div>Hello name!</div>; const Bold = ; <Bold>This is bold</Bold> // <b>This is bold</b> <Bold ="i">Tricked you its italics</Bold> // <i>Tricked you its italics</i> <Bold = /> // <div>Hello !</div> <Bold = /> // <div>Hello Joe!</div>
Using the HOC
import withAs from 'react-render-as'; const Table = children children; Table 'table';