Skip to content

Commit d4cd586

Browse files
committed
Handle mapArray/indexArray edge cases; support member expression custom hooks.
1 parent 4c2d3af commit d4cd586

File tree

3 files changed

+247
-132
lines changed

3 files changed

+247
-132
lines changed

docs/reactivity.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,16 @@ function createCustomStore() {
237237
);
238238
}
239239

240+
const [array] = createSignal([]);
241+
const result = mapArray(array, (item, i) => {
242+
i();
243+
});
244+
245+
const [array] = createSignal([]);
246+
const result = indexArray(array, (item) => {
247+
item();
248+
});
249+
240250
```
241251

242252
### Valid Examples
@@ -411,6 +421,12 @@ function createFoo(v) {}
411421
const [bar, setBar] = createSignal();
412422
createFoo({ onBar: () => bar() });
413423

424+
const [bar, setBar] = createSignal();
425+
X.createFoo(() => bar());
426+
427+
const [bar, setBar] = createSignal();
428+
X.Y.createFoo(() => bar());
429+
414430
const [signal, setSignal] = createSignal(1);
415431
const element = document.getElementById("id");
416432
element.addEventListener(
@@ -489,6 +505,10 @@ css`
489505

490506
html`<div>${(props) => props.name}</div>`;
491507

508+
styled.css`
509+
color: ${(props) => props.color};
510+
`;
511+
492512
function Component() {
493513
let canvas;
494514
return <canvas ref={canvas} />;
@@ -528,6 +548,16 @@ function createCustomStore() {
528548
);
529549
}
530550

551+
function createCustomStore() {
552+
const [store, updateStore] = createStore({});
553+
554+
return indexArray(
555+
// the first argument to mapArray is a tracked scope
556+
() => store.path.to.field,
557+
(item) => ({})
558+
);
559+
}
560+
531561
```
532562
<!-- AUTO-GENERATED-CONTENT:END -->
533563

0 commit comments

Comments
 (0)