Loading...
Loading...
SolidJS reactive UI library. Covers signals, effects, and fine-grained reactivity. USE WHEN: user mentions "SolidJS", "Solid", "createSignal", "createEffect", "createMemo", "fine-grained reactivity", asks about "Solid patterns", "reactive primitives" DO NOT USE FOR: React - use `frontend-react` (different API despite similar JSX), Vue - use `vue-composition`, Svelte - use `svelte`, Angular - use `angular`
npx skill4agent add claude-dev-suite/claude-dev-suite solidFull Reference: See advanced.md for WebSocket primitive, context provider, chat component, room management, Socket.IO integration, and store patterns.
Deep Knowledge: Usewith technology:mcp__documentation__fetch_docsfor comprehensive documentation.solid
frontend-reactvue-compositionsvelteangularimport { createSignal, createEffect, createMemo } from 'solid-js';
interface Props {
name: string;
count?: number;
}
function Counter(props: Props) {
const [localState, setLocalState] = createSignal('');
const doubled = createMemo(() => (props.count ?? 0) * 2);
createEffect(() => {
console.log('Count changed:', props.count);
});
return (
<div>
<h1>Hello {props.name}</h1>
<p>Doubled: {doubled()}</p>
<button onClick={() => setLocalState('clicked')}>
Click
</button>
</div>
);
}| API | Purpose |
|---|---|
| Reactive state |
| Cached computation |
| Side effects |
| Async data fetching |
| Nested reactive objects |
props.nameimport { Show, For, Switch, Match } from 'solid-js';
<Show when={isLoggedIn()} fallback={<Login />}>
<Dashboard />
</Show>
<For each={items()}>{(item) => <Item data={item} />}</For>| Anti-Pattern | Why It's Bad | Correct Approach |
|---|---|---|
| Destructuring props | Loses reactivity | Access via |
| Using React patterns | Different paradigm | Use Solid primitives |
Not using | Manual conditional logic | Use |
| Recreating signals in components | Components run once | Create outside or use stores |
Using | XSS vulnerability | Use DOMPurify |
Not cleaning up in | Memory leaks | Add cleanup logic |
| Issue | Likely Cause | Solution |
|---|---|---|
| Props not reactive | Destructured props | Access via |
| Signal not updating | Forgot to call setter | Use |
| Effect not running | Not tracking signal | Call signal inside effect: |
| Component re-running | Treating like React | Components run once, use signals |
| List not updating | Using array methods | Use |
| Memory leaks | No cleanup | Use |
import { ErrorBoundary } from 'solid-js';
function App() {
return (
<ErrorBoundary
fallback={(err, reset) => (
<div>
<p>Error: {err.message}</p>
<button onClick={reset}>Retry</button>
</div>
)}
>
<MainContent />
</ErrorBoundary>
);
}// Lazy loading components
const HeavyComponent = lazy(() => import('./HeavyComponent'));
function App() {
return (
<Suspense fallback={<Loading />}>
<HeavyComponent />
</Suspense>
);
}
// Batch updates (rarely needed)
import { batch } from 'solid-js';
batch(() => {
setCount(count() + 1);
setName('New Name');
});import { createStore, produce } from 'solid-js/store';
const [state, setState] = createStore({
users: [] as User[],
filters: { active: true },
});
// Immutable-style updates with produce
function addUser(user: User) {
setState(produce((s) => {
s.users.push(user);
}));
}
// Path-based updates
setState('users', (users) => [...users, newUser]);
setState('filters', 'active', false);import { render, screen } from '@solidjs/testing-library';
import userEvent from '@testing-library/user-event';
import Counter from './Counter';
describe('Counter', () => {
it('increments on click', async () => {
const user = userEvent.setup();
render(() => <Counter initial={0} />);
const button = screen.getByRole('button');
await user.click(button);
expect(screen.getByText('Count: 1')).toBeInTheDocument();
});
});// innerHTML - only with trusted content
<div innerHTML={sanitizedHtml} />
// Prefer text content
<div>{userInput}</div> // Safe - auto-escaped
// XSS prevention
import DOMPurify from 'dompurify';
function SafeHtml(props: { html: string }) {
const clean = () => DOMPurify.sanitize(props.html);
return <div innerHTML={clean()} />;
}| Metric | Target |
|---|---|
| Bundle size | < 30KB |
| First Contentful Paint | < 1s |
| Time to Interactive | < 1.5s |
| Memory usage | Stable |
Deep Knowledge: Usewith technology:mcp__documentation__fetch_docsfor comprehensive documentation.solid