# Yarn
yarn add gasly -D
# NPM
npm install gasly -D
First, create a directory named .gasly
at the root of your project. Inside it, create a file which contains a snippet that you will often use, for example a react component written in Typescript:
/* .gasly/TsxComponent.tsx */
import { FC } from 'react';
type Props = {
};
const TsxComponent: FC<Props> = ({ }) => {
return (
<></>
);
};
export default TsxComponent;
See how the component is named the same way as the file, this is important.
Then run:
npx gasly
...and choose the snippet you just created, the path where your new file will be located, and its name (ex: TsxComponent.tsx
, src/components
, Navbar
). If everything worked as expected, you can now edit your new file π ! Notice how all the occurrences of the string TsxComponent
where replaced by the name you chose.
The example above works exactly the same way with directories, if you want to divide a component in multiple files.
See this example.
MIT Β© Colin Lienard