Skip to content

Instantly share code, notes, and snippets.

@josefaidt
Created June 21, 2020 01:12
Show Gist options
  • Save josefaidt/6523f8d75c3cd08d0af87fab105448bd to your computer and use it in GitHub Desktop.
Save josefaidt/6523f8d75c3cd08d0af87fab105448bd to your computer and use it in GitHub Desktop.
function _create_react_component
if test (count $argv) -lt 1
read -l -P "Name of component? " component
_create_react_component $component
else
set cmp $argv[1]
mkdir -p components/$cmp
echo "
import React from 'react'
import styles from './$cmp.module.css'
export default function $cmp({ children, ...rest }) {
return (
)
}
" > components/$cmp/$cmp.js
touch components/$cmp/$cmp.module.css
echo "export { default } from './$cmp'" > components/$cmp/index.js
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment