Skip to content

Commit 8acb419

Browse files
committed
Formatting
1 parent db22e3c commit 8acb419

File tree

1 file changed

+46
-43
lines changed

1 file changed

+46
-43
lines changed

docs/reactivity.md

Lines changed: 46 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<!-- AUTO-GENERATED-CONTENT:START (HEADER) -->
2-
32
# solid/reactivity
4-
53
Enforce that reactivity (props, signals, memos, etc.) is properly used, so changes in those values will be tracked and update the view as expected.
64
This rule is **a warning** by default.
75

@@ -149,11 +147,10 @@ warnings can be safely ignored.
149147
</details> -->
150148

151149
<!-- AUTO-GENERATED-CONTENT:START (OPTIONS) -->
152-
150+
153151
<!-- AUTO-GENERATED-CONTENT:END -->
154152

155153
<!-- AUTO-GENERATED-CONTENT:START (CASES) -->
156-
157154
## Tests
158155

159156
### Invalid Examples
@@ -166,41 +163,41 @@ const Component = () => {
166163
console.log(signal());
167164
return null;
168165
};
169-
166+
170167
const Component = () => {
171168
const [signal] = createSignal(5);
172169
console.log(signal());
173170
return <div>{signal()}</div>;
174171
};
175-
172+
176173
const Component = (props) => {
177174
const value = props.value;
178175
return <div>{value()}</div>;
179176
};
180-
177+
181178
const Component = (props) => {
182179
const { value: valueProp } = props;
183180
const value = createMemo(() => valueProp || "default");
184181
return <div>{value()}</div>;
185182
};
186-
183+
187184
const Component = (props) => {
188185
const valueProp = props.value;
189186
const value = createMemo(() => valueProp || "default");
190187
return <div>{value()}</div>;
191188
};
192-
189+
193190
const Component = (props) => {
194191
const derived = () => props.value;
195192
const oops = derived();
196193
return <div>{oops}</div>;
197194
};
198-
195+
199196
function Component(something) {
200197
console.log(something.a);
201198
return <div />;
202199
}
203-
200+
204201
const Component = () => {
205202
const [signal] = createSignal();
206203
const d = () => {
@@ -209,7 +206,7 @@ const Component = () => {
209206
};
210207
d(); // not ok
211208
};
212-
209+
213210
const Component = () => {
214211
const [signal] = createSignal();
215212
function d() {
@@ -218,7 +215,7 @@ const Component = () => {
218215
}
219216
d(); // not ok
220217
};
221-
218+
222219
const Component = () => {
223220
const [signal] = createSignal();
224221
const d = () => {
@@ -231,7 +228,7 @@ const Component = () => {
231228
};
232229
d(); // not ok
233230
};
234-
231+
235232
const Component = () => {
236233
const [signal1] = createSignal();
237234
const d = () => {
@@ -245,7 +242,7 @@ const Component = () => {
245242
e(); // not ok, signal2 is in scope
246243
};
247244
};
248-
245+
249246
const Component = () => {
250247
const [signal] = createSignal();
251248
const foo = () => {
@@ -258,75 +255,79 @@ const Component = () => {
258255
};
259256
bar(); // not ok
260257
};
261-
258+
262259
const Component = () => {
263260
createSignal();
264261
};
265-
262+
266263
const Component = () => {
267264
const [, setSignal] = createSignal();
268265
};
269-
266+
270267
const Component = () => {
271268
createMemo(() => 5);
272269
};
273-
270+
274271
const Component = () => {
275272
const [signal] = createSignal();
276273
return <div>{signal}</div>;
277274
};
278-
275+
279276
const Component = () => {
280277
const memo = createMemo(() => 5);
281278
return <div>{memo}</div>;
282279
};
283-
280+
284281
const Component = () => {
285282
const [signal] = createSignal();
286283
return <button type={signal}>Button</button>;
287284
};
288-
285+
289286
const Component = () => {
290287
const [signal] = createSignal();
291288
return <div>{signal}</div>;
292289
};
293-
290+
294291
const Component = () => {
295292
const [signal] = createSignal("world");
296293
const memo = createMemo(() => "hello " + signal);
297294
};
298-
295+
299296
const Component = () => {
300297
const [signal] = createSignal("world");
301298
const memo = createMemo(() => `hello ${signal}`);
302299
};
303-
300+
304301
const Component = () => {
305302
const [signal] = createSignal(5);
306303
const memo = createMemo(() => -signal);
307304
};
308-
305+
309306
const Component = (props) => {
310307
const [signal] = createSignal(5);
311308
const memo = createMemo(() => props.array[signal]);
312309
};
313-
310+
314311
const Component = (props) => {
315312
return <div onClick={props.onClick} />;
316313
};
317-
314+
318315
const Component = (props) => {
319316
createEffect(props.theEffect);
320317
};
321-
318+
322319
const Component = (props) => {
323-
return <SomeContext.Provider value={props.value}>{props.children}</SomeContext.Provider>;
320+
return (
321+
<SomeContext.Provider value={props.value}>
322+
{props.children}
323+
</SomeContext.Provider>
324+
);
324325
};
325-
326+
326327
const Component = (props) => {
327328
return <SomeProvider value={props.value}>{props.children}</SomeProvider>;
328329
};
329-
330+
330331
const Component = (props) => {
331332
const [signal] = createSignal();
332333
return (
@@ -335,54 +336,57 @@ const Component = (props) => {
335336
</SomeContext.Provider>
336337
);
337338
};
338-
339+
339340
const owner = getOwner();
340341
const [signal] = createSignal();
341342
createEffect(() => runWithOwner(owner, () => console.log(signal())));
342-
343+
343344
function Component() {
344345
const owner = getOwner();
345346
const [signal] = createSignal();
346347
createEffect(() => runWithOwner(owner, () => console.log(signal())));
347348
}
348-
349+
349350
const [count, setCount] = createSignal(0);
350351
createEffect(async () => {
351352
await Promise.resolve();
352353
console.log(count());
353354
});
354-
355+
355356
const [photos, setPhotos] = createSignal([]);
356357
createEffect(async () => {
357-
const res = await fetch("https://jsonplaceholder.typicode.com/photos?_limit=20");
358+
const res = await fetch(
359+
"https://jsonplaceholder.typicode.com/photos?_limit=20"
360+
);
358361
setPhotos(await res.json());
359362
});
360-
363+
361364
const [signal] = createSignal("red");
362365
css`
363366
color: ${signal};
364367
`;
365-
368+
366369
const [signal] = createSignal("red");
367370
const f = () => signal();
368371
css`
369372
color: ${f};
370373
`;
371-
374+
372375
function createCustomStore() {
373376
const [store, updateStore] = createStore({});
374377
return mapArray([], (item) => store.path.to.field);
375378
}
376-
379+
377380
const [array] = createSignal([]);
378381
const result = mapArray(array, (item, i) => {
379382
i();
380383
});
381-
384+
382385
const [array] = createSignal([]);
383386
const result = indexArray(array, (item) => {
384387
item();
385388
});
389+
386390
```
387391

388392
### Valid Examples
@@ -716,7 +720,6 @@ function Component(props) {
716720
}
717721

718722
```
719-
720723
<!-- AUTO-GENERATED-CONTENT:END -->
721724

722725
## Implementation

0 commit comments

Comments
 (0)