MCPcopy Create free account
hub / github.com/bholmesdev/simplestack-store / ConditionalComponent

Function ConditionalComponent

src/react.test.tsx:613–633  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

611 const noteStore = store({ id: 5, title: "Story" });
612
613 function ConditionalComponent() {
614 const id = useStoreValue(idStore);
615 const title = useStoreValue(noteStore, (value) => {
616 if (id === value.id) {
617 return value.title;
618 }
619 });
620
621 return (
622 <div>
623 <span data-testid="result">{title ?? "undefined"}</span>
624 <button
625 type="button"
626 data-testid="increment"
627 onClick={() => idStore.set((n) => n + 1)}
628 >
629 Increment
630 </button>
631 </div>
632 );
633 }
634
635 render(<ConditionalComponent />);
636

Callers

nothing calls this directly

Calls 1

useStoreValueFunction · 0.85

Tested by

no test coverage detected