Skip to content

Commit 86e2e3e

Browse files
committed
remove usage examples
1 parent 6579274 commit 86e2e3e

File tree

1 file changed

+0
-85
lines changed

1 file changed

+0
-85
lines changed

src/routes/reference/basic-reactivity/create-signal.mdx

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -101,91 +101,6 @@ Returns a tuple `[getter, setter]` where:
101101

102102
## Usage
103103

104-
### Creating a signal with an initial value
105-
106-
```typescript
107-
const [count, setCount] = createSignal(0);
108-
109-
console.log(count()); // 0
110-
setCount(5);
111-
console.log(count()); // 5
112-
```
113-
114-
### Creating a signal without an initial value
115-
116-
```typescript
117-
const [name, setName] = createSignal<string>();
118-
119-
console.log(name()); // undefined
120-
setName("John");
121-
console.log(name()); // "John"
122-
```
123-
124-
### Functional updates
125-
126-
```typescript
127-
const [count, setCount] = createSignal(0);
128-
129-
setCount(prev => prev + 1);
130-
console.log(count()); // 1
131-
132-
setCount(c => c * 2);
133-
console.log(count()); // 2
134-
```
135-
136-
## Advanced Usage
137-
138-
### Using a custom equality function
139-
140-
```typescript
141-
const [user, setUser] = createSignal(
142-
{ name: "John", age: 25 },
143-
{
144-
equals: (prev, next) => prev.name === next.name && prev.age === next.age
145-
}
146-
);
147-
148-
// This won't trigger updates because the values are considered equal
149-
setUser({ name: "John", age: 25 });
150-
```
151-
152-
### Disabling equality checking
153-
154-
```typescript
155-
const [data, setData] = createSignal([], { equals: false });
156-
157-
// This will always trigger updates, even with the same array reference
158-
setData([]);
159-
```
160-
161-
### Development debugging
162-
163-
```typescript
164-
const [state, setState] = createSignal(
165-
{ loading: false, data: null },
166-
{ name: "apiState" }
167-
);
168-
```
169-
170-
## Common Patterns
171-
172-
### Boolean toggle
173-
174-
```typescript
175-
const [isOpen, setIsOpen] = createSignal(false);
176-
const toggle = () => setIsOpen(prev => !prev);
177-
```
178-
179-
### Object updates
180-
181-
```typescript
182-
const [user, setUser] = createSignal({ name: "John", age: 25 });
183-
184-
// Update specific property
185-
const updateName = (newName: string) =>
186-
setUser(prev => ({ ...prev, name: newName }));
187-
```
188-
189104
## How It Works
190105

191106
Signals are the foundational primitive of SolidJS's fine-grained reactivity system.

0 commit comments

Comments
 (0)