Skip to content

wbroberts/go-react

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go React

Wanted to learn Go so started with a simple CLI to can create the boilerplate for files.

Install

go install github.com/wbroberts/go-react@latest

Use

go-react

Component

Creates a component and component test file.

go-react component <ComponentName>

Options:

  • --props or -p adds an empty props type for component
  • --skip-tests skips adding the test file
  • --dir or -d sets the path for the directory the component should be added to. Will create the directory if it does not exist yet

Example

go-react component Example
  • Component ./components/Example.component.tsx
import React from 'react';

export const Example = () => {
  return <div>Example renders</div>;
}
  • Component test ./components/Example.component.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();
  });
});

Optional Config File for Defaults

Can add a config file to set default flags when running commands.

touch go-react.yaml

# All values are optional
component:
  dir: src/components
  props: true
  skip-tests: false

About

Simple CLI tool to generate React files

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages