#react #component #cli-tool #generate #boilerplate #tsx #path

app react-component

A CLI tool to generate React component files

9 releases

0.2.6 Mar 3, 2023
0.2.5 Feb 27, 2023
0.1.2 Feb 2, 2023

#798 in Command line utilities

Download history 118/week @ 2024-02-24 113/week @ 2024-03-02

156 downloads per month

MIT license

10KB
225 lines

React Component

I wanted to learn Rust and wanted to compare it to Go. So I made a simple CLI tool to generate some boilerplate react component files.

Installation

cargo install react-component

How To Use

react-component --help
react-component <component name> <...options>

Example

react-component Example --path src/components/examples

Generates three files:

  • src/components/examples/Example.component.tsx
import React from 'react';

export type ExampleProps = {};

export const Example: React.ComponentType<ExampleProps> = ({}) => {
  return (<div>Example renders</div>);
};
  • src/components/examples/Example.test.tsx
import { screen, render } from '@testing-library/react';

import { Example } from './Example.component';

describe('Example', () => {
  it('renders', () => {
    render(<Example />);
    expect(screen.getByText(/Example renders/)).toBeDefined();
  });
});
  • src/components/examples/Example.stories.tsx
import { ComponentMeta, Story } from '@storybook/react';

import { Example, ExampleProps } from './Example.component';

const story: ComponentMeta<typeof Example> = {
  title: 'Example'
};

export const ExampleStory: Story<ExampleProps> = (args) => {
  return (<Example {...args} />)
};

export default story;

Dependencies

~2–11MB
~105K SLoC