Crates.io | react-component |
lib.rs | react-component |
version | 0.2.6 |
source | src |
created_at | 2023-02-02 23:18:53.889349 |
updated_at | 2023-03-03 23:13:44.618003 |
description | A CLI tool to generate React component files |
homepage | |
repository | https://github.com/wbroberts/react-component |
max_upload_size | |
id | 775233 |
size | 20,667 |
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.
cargo install react-component
react-component --help
react-component <component name> <...options>
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;