A collection of essential React snippets for Zed code editor that boosts your development workflow with smart shortcuts for common React patterns and hooks.
- 🚀 30+ essential React snippets
- ⚡️ Lightning-fast component scaffolding
- 🎣 All major React hooks support
- 🧩 Common patterns like context providers, prop types, and event handlers
- 📝 JSX and TypeScript friendly
- Open Zed editor
- Go to `Extensions` in the command palette (`Cmd+K`)
- Search for "React Snippets"
- Click `Install`
Type the prefix and press `Tab` to expand the snippet. Use `Tab` and `Shift+Tab` to navigate between placeholders.
| Prefix | Description | Snippet Preview |
|---|---|---|
| `rfc` | Function component | `function Component() { ... }` |
| `rfce` | Default Export Function component | `default export function Component() { ... }` |
| `rfcp` | Component with props | `function Component({ prop }) { ... }` |
| `rfce` | Component with export | `export default function Component() {...}` |
| `memo` | Memoized component | `React.memo(Component)` |
| `frag` | React Fragment | `<></>` |
| `rsc` | React Stateless Component | `function Component() { ... }` |
| Prefix | Description | Snippet Preview |
|---|---|---|
| `rsta` | State hook | `const [state, setState] = useState()` |
| `reff` | Effect hook | `useEffect(() => {...}, [])` |
| `rcon` | Context hook | `const ctx = useContext(Context)` |
| `rref` | Ref hook | `const ref = useRef()` |
| `rmem` | Memoization hook | `const value = useMemo(() => ...)` |
| `rcal` | Callback hook | `const cb = useCallback(() => ...)` |
| Prefix | Description | Snippet Preview |
|---|---|---|
| `handler` | Generic event handler | `const handleEvent = (e) => {...}` |
| `onClick` | Click handler | `onClick={handleClick}` |
| `onChange` | Change handler | `onChange={handleChange}` |
| `onSubmit` | Form submit handler | `onSubmit={handleSubmit}` |
| Prefix | Description | Snippet Preview |
|---|---|---|
| `cond` | Conditional rendering | `{condition ? a : b}` |
| `map` | Array mapping | `{array.map(item => ...)}` |
| `context` | Context provider | `const Context = createContext()` |
| `styled` | Styled component | `const Styled = styled.div`... |
| `ptypes` | PropTypes definition | `Component.propTypes = {...}` |
| Prefix | Description | Snippet Preview |
|---|---|---|
| `imr` | Import React | `import React from 'react'` |
| `imrh` | Import React with hooks | `import React, { useState } from 'react'` |
| `impt` | Import PropTypes | `import PropTypes from 'prop-types'` |
- Create a new component file
- Type `rfce` + `Tab` to scaffold a component
- Add state with `useState` + `Tab`
- Add effect with `useEffect` + `Tab`
- Add click handler with `onClick` + `Tab`
```jsx function Counter() { const [count, setCount] = useState(0); // ← useState snippet
useEffect(() => { // ← useEffect snippet document.title = `Count: ${count}`; }, [count]);
const handleClick = () => { // ← handler snippet setCount(c => c + 1); };
return ( // ← onClick snippet Count: {count} ); }
export default Counter; ```
Contributions are welcome! To add new snippets:
- Fork the repository
- Add your snippets to `snippets.json`
- Submit a pull request
Happy Coding! 🚀 Boost your React development with these essential Zed snippets.`;