Technical Interview Questions
Question 1: What are signals in SolidJS and how do they differ from React’s useState?
Signals are SolidJS’s fundamental reactive primitive, consisting of a getter and setter function pair.
Unlike React’s useState which triggers component re-renders, signals update only the specific computations that depend on them.
This fine-grained reactivity means SolidJS components run once, with only reactive expressions updating when dependencies change.
Question 2: Explain SolidJS’s fine-grained reactivity system and its performance advantages.
Fine-grained reactivity tracks dependencies at the expression level rather than component level like React.
When a signal changes, only the specific DOM nodes or computations depending on it update automatically.
This eliminates diffing algorithms and unnecessary work, making SolidJS one of the fastest frameworks in benchmarks.
Question 3: How do effects work in SolidJS and when should you use createEffect?
Effects automatically track signal dependencies and re-run when those dependencies change without explicit dependency arrays.
The createEffect function schedules side effects to run after rendering but before browser paint.
Use effects for side effects like logging, analytics, or syncing with external systems, not for deriving state.
Question 4: What is the difference between createMemo and createEffect?
createMemo returns a read-only signal that caches derived computations, re-calculating only when dependencies change.
createEffect performs side effects and returns nothing, running for effects rather than value computation.
Use memos for expensive calculations you want to reuse, and effects for actions like DOM manipulation or API calls.
Question 5: How does SolidJS handle control flow and why are components like Show and For important?
SolidJS provides control flow components like Show, For, Switch, and Index for conditional rendering and lists.
These components are essential because JavaScript’s logical operators and map don’t create reactive scopes properly.
Using Show instead of && ensures proper cleanup and reactivity tracking within conditional branches.
Question 6: Explain the concept of ownership and disposal in SolidJS.
Ownership creates a parent-child relationship between computations, enabling automatic cleanup when parents dispose.
When a component unmounts or conditional logic removes elements, SolidJS automatically disposes associated effects and resources.
This system prevents memory leaks without requiring manual cleanup functions like React’s useEffect return values.
Question 7: How do you manage global state in SolidJS applications?
Global state can be created using signals defined outside components and imported where needed.
SolidJS also provides createStore for nested reactive objects with granular updates at any property path.
The store API supports immer-like mutations while maintaining immutability and reactivity guarantees.
| State Management |
Use Case |
API |
Granularity |
| createSignal |
Simple values |
signal, setSignal |
Full value |
| createStore |
Nested objects |
store, setStore |
Property path |
| Context API |
Dependency injection |
createContext, useContext |
Provider scope |
| Global signals |
App-wide state |
Module-level signals |
Full value |
| createRoot |
Isolated scope |
Disposal function |
Root boundary |
Question 8: What is createStore and how does it differ from createSignal?
createStore creates a proxy-based reactive object that tracks granular property access and updates.
Unlike signals which replace entire values, stores allow updating nested properties while maintaining reactivity.
Stores are ideal for complex state shapes like forms, lists of objects, or deeply nested data structures.
Question 9: How do you handle asynchronous data fetching in SolidJS?
SolidJS provides createResource for handling async operations with built-in loading and error states.
Resources integrate with Suspense boundaries for coordinated loading experiences across multiple async operations.
The fetcher function automatically re-runs when source signals change, providing reactive data fetching capabilities.
Question 10: Explain SolidJS’s Context API and how it compares to React’s Context.
SolidJS Context uses the same Provider-Consumer pattern but without re-rendering limitations since there are no re-renders.
Context values can be signals, stores, or any JavaScript value, with consumers automatically tracking used dependencies.
This makes SolidJS Context more performant than React’s, as updates only affect specific consuming expressions.
Question 11: What are resources and how do they work with Suspense?
Resources wrap async operations and provide loading, error, and data states through signal-like accessors.
When a resource is loading, it triggers parent Suspense boundaries to show fallback content.
The createResource API supports refetching, SSR serialization, and automatic caching strategies.
Question 12: How does SolidJS optimize rendering and what is the compilation process?
SolidJS uses a compiler to transform JSX into optimized DOM operations with minimal runtime overhead.
The compiler identifies static vs dynamic portions of templates, updating only dynamic parts reactively.
This AOT compilation approach produces smaller bundles and faster runtime code than virtual DOM frameworks.
Question 13: What are SolidJS directives and how do you create custom ones?
Directives are special attributes prefixed with use: that provide ref-like functionality with automatic cleanup.
Built-in directives include use:portal, use:model, and use:aria while custom directives extend functionality.
Directives receive the element and accessor function, enabling imperative DOM operations within reactive contexts.
Question 14: How do you implement forms in SolidJS with proper validation?
Forms use signals or stores to track input values with controlled or uncontrolled input patterns.
Libraries like solid-forms provide form state management, validation, and submission handling.
The bindings tutorial covers two-way binding patterns using value and onInput handlers.
Question 15: Explain SolidJS’s approach to component composition and reusability.
Components in SolidJS are functions that run once, returning DOM nodes with embedded reactive expressions.
Props are accessed through getters to maintain reactivity, using destructuring carefully to avoid losing reactivity.
Higher-order components and render props work naturally, while hooks are replaced by reactive primitives.
Question 16: How do you handle routing in SolidJS applications?
The official @solidjs/router provides declarative routing with nested routes and data loading integration.
Routes can load data using route-level resources, integrating with Suspense for loading states.
The router supports file-based routing in SolidStart and programmatic navigation through useNavigate and useParams.
Question 17: What is SolidStart and how does it enable full-stack SolidJS development?
SolidStart is SolidJS’s meta-framework for SSR, SSG, and full-stack applications similar to Next.js.
It provides file-based routing, API routes, middleware, and deployment adapters for various platforms.
The framework enables isomorphic data loading with server functions that work seamlessly between client and server.
Question 18: How do you test SolidJS components and applications?
Testing uses solid-testing-library which provides utilities similar to React Testing Library.
Tests render components in reactive roots, query elements, and trigger events while assertions verify behavior.
Unit tests focus on reactive primitives, while integration tests verify component interactions and data flow.
| Testing Approach |
Tool |
Focus Area |
Best Practice |
Example |
| Unit Testing |
Vitest |
Reactive primitives |
Test signal behavior |
Signal updates |
| Component Testing |
solid-testing-library |
Component behavior |
User interaction |
Click handlers |
| Integration Testing |
Playwright |
Feature workflows |
End-to-end flows |
Form submission |
| Visual Testing |
Storybook |
UI components |
Snapshot comparison |
Button states |
Question 19: What are the key differences between SolidJS and React that affect development?
SolidJS components run once vs React’s repeated renders, fundamentally changing how you think about component lifecycle.
Props are getters requiring careful handling to preserve reactivity, unlike React’s plain object props.
No dependency arrays are needed since SolidJS automatically tracks dependencies in reactive contexts.
Question 20: How do you optimize SolidJS applications for production?
SolidJS apps are optimized by default through compilation, but further improvements include code splitting and lazy loading.
Use the lazy function for dynamic imports and the lazy component wrapper for route-based splitting.
Profile applications using browser DevTools to identify unnecessary computations or effects causing performance issues.