Skip to content

Instantly share code, notes, and snippets.

@swapnilmishra
Last active August 24, 2016 16:59
Show Gist options
  • Save swapnilmishra/0049b41507fb82f5b96db2cf0f8a1836 to your computer and use it in GitHub Desktop.
Save swapnilmishra/0049b41507fb82f5b96db2cf0f8a1836 to your computer and use it in GitHub Desktop.
Script to create component and index file
echo -n "Enter Component name > "
read componentName
mkdir -p -- "$componentName"
cd $componentName
{
echo "import React, { Component } from 'react';"
echo "import { observer, inject } from 'mobx-react';"
echo "import styles from './style.scss';"
echo "@observer"
echo "class '$componentName' extends Component {"
echo " render() {"
echo " return ("
echo " <div className = 'test-component'>"
echo "{'test component'}"
echo '</div>'
echo ');'
echo '}'
echo '}'
echo "export default '$componentName";''
} >$componentName.jsx
{
echo "import '$componentName' from './"$componentName"';"
echo ""
echo "export default '$componentNam'";"
} >index.js
{
echo ""
} >style.scss
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment