A comprehensive collection of React and TypeScript snippets for the Zed IDE to improve your development speed and productivity.
This extension provides a comprehensive set of snippets for React and TypeScript development, including:
.tsx and .ts files!React. prefixes!)git clone https://github.com/vishnuroshan/zed-react-ts-snippets.git
or TypeScript file and press Tab to expand the snippet.
.tsx files: All snippets available (components, hooks, types, etc.).ts files: React hooks and TypeScript utility snippets available
.hook.ts files)rfc) in a TSX file and press Tab to expand the snippet.Prefix (.tsx and .ts) |
Description |
|---|---|
| React Components | |
rfc |
React Functional Component (const) |
rff |
React Functional Component (function) |
frc |
ForwardRef Component with props |
hk |
Custom Hook Template |
rctx |
React Context with Provider and hook |
| React Hooks | |
us |
useState Hook with TypeScript |
uem |
useEffect Hook runs once at mount |
uer |
useEffect Hook runs on every render |
cleanup |
useEffect Hook Cleanup |
useMemo |
useMemo Hook |
useCallback |
useCallback Hook |
useRef |
useRef Hook |
uih |
useImperativeHandle Hook |
useLayoutEffect |
useLayoutEffect Hook |
useDebugValue |
useDebugValue Hook |
useContext |
useContext Hook |
useReducer |
useReducer Hook |
| TypeScript Types | |
tst |
New Type Alias |
tsi |
New Interface |
intr |
Interface |
typ |
Type |
enum |
Enum |
tsrcd |
Record utility type |
tgf |
Type Guard Function |
| Functions & Classes | |
tsfn |
Function Declaration |
tsafn |
Arrow Function |
func |
Function |
tscls |
Class with Constructor |
tsserv |
Generic Service Class Template |
| Imports & Exports | |
tsimprt |
Import Statement |
tsxprt |
Module Export |
| Utilities | |
tsfetch |
Typed Fetch Function |
tstc |
Try/Catch block |
type { FC } from 'react';
interface ComponentNameProps {
propName: type;
}
const ComponentName: FC<ComponentNameProps> = ({ propName }) => {
return <div></div>;
};
export default ComponentName;
Type us and press Tab:
const [state, setState] = useState<type>(initialValue);
Now works in .ts files too! Perfect for custom hooks:
// useCounter.hook.ts
import { useState } from 'react';
export function useCounter(initialValue: number) {
const [count, setCount] = useState<number>(initialValue); // Type 'us' + Tab
// ... rest of hook logic
}
Type uem and press Tab:
---
### useEffect Hook
Type `uem` and press Tab:
```tsx
React.useEffect(() => {}, []);
Type tsi and press Tab:
interface InterfaceName {
key: type;
}
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.
Vishnu Roshan - vishnuroshan