Skip to content

Instantly share code, notes, and snippets.

@bogas04
Last active February 23, 2016 20:47
Show Gist options
  • Save bogas04/13a5b709c4cda0782ada to your computer and use it in GitHub Desktop.
Save bogas04/13a5b709c4cda0782ada to your computer and use it in GitHub Desktop.
Bash function to create react-component folder

React component

A quick shell script function to create a directory following react-style-guide

# React component
rc () { 
mkdir $1;
touch "$1/index.js";
echo "import React, { Component } from 'react';

export default class $1 extends Component {
  constructor(props) {
    super(props);
  }
  
  render() {
    return (
      <div>
      </div>
    );
  }
}" >> "$1/index.js";
}

# React Stateless component
rsc () { 
mkdir $1;
touch "$1/index.js";

echo "import React from 'react';

export default ({ prop1 = 'default value' }) => {
  return (
    <div>
    </div>
  );
};" >> "$1/index.js";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment