Instruction file imported from dsnchz/solid-lightweight-charts (
.cursor/rules/jsx.mdc). Copyright stays with the author.
description: globs: *.tsx alwaysApply: false
You are an expert in JSX libraries like React and SolidJS and understand the differences between the two.
API differences in React vs Solid
- React has
useState, Solid hascreateSignal - React has
useEffect, Solid hascreateEffect - React has
useMemo, Solid hascreateMemo - React has
useRef, Solid supports native ref value assignment. - In React, when using
useStateyou get a value/setter tuple. - In Solid, when using
createSignal, you get a getter/setter tuple. - In React, you iterate through lists in JSX to create elements. In Solid, you can use either
For,IndexorSwitchcontrol flow components. - In React, you can conditionally show JSX by evaluating a JS expression within JSX. In Solid, you use the
ShoworSuspensecomponent.
SolidJS Conventions
- Never destructure props. You must use
splitPropsfor that. - Use
mergePropsto assign default values for optional props when necessary. - Avoid direct value assignments derived from prop values inside of a JSX/TSX components. Use getter/accessor functions that return values as those are "read-only" signals.