@ts-delight/class-to-component
    TypeScript icon, indicating that this package has built-in type declarations

    2.0.2 • Public • Published

    About

    class-to-component is a simple library that takes in a class name and gives you back a react component which renders a container with that class name applied.

    This is especially useful in conjunction with css-modules or css-in-js libraries like typestyle.

    Basic usage:

    import classToComponent from '@ts-delight/class-to-component';
     
    const C = classToComponent('foo');
     
    // Now you can use C as a component:
    const Container = () => <C />
    // Renders <div className="foo" />

    We can also pass multiple class names (which are combined using classcat):

    const C = classToComponent(['foo', 'bar']);

    Advanced Usage:

    const ListView = classToComponent({
        element: "span", // div by default
        class: ['foo', 'bar'],
        displayName: 'ListView'
        // Also see: https://github.com/ts-delight/inject-display-name.macro
    });
     
    // Later:
    <ListView useCompactView />

    License

    MIT

    Install

    npm i @ts-delight/class-to-component

    DownloadsWeekly Downloads

    3

    Version

    2.0.2

    License

    MIT

    Unpacked Size

    20.5 kB

    Total Files

    12

    Last publish

    Collaborators

    • lorefnon