MCPcopy Create free account
hub / github.com/thetarnav/solid-devtools / Todos

Function Todos

examples/sandbox/src/Todos.tsx:48–135  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

46}
47
48const Todos: s.Component<{title: string}> = (props) => {
49
50 const [newTitle, setTitle] = s.createSignal('')
51 const [todos, setTodos] = createLocalStore('todos-2', {
52 values: [] as TodoItem[],
53 other: {
54 name: 'todos',
55 get newTitle() {
56 return {value: newTitle()}
57 },
58 countOuter: {
59 countInner: {
60 count: 0,
61 },
62 },
63 },
64 })
65
66 const valuesInASignal = s.createMemo(() => ({values: todos.values}))
67
68 // @ts-ignore
69 setTodos('other', 'else', unwrap(todos.values))
70
71 const addTodo = (e: SubmitEvent) => {
72 e.preventDefault()
73 s.batch(() => {
74 setTodos('values', todos.values.length, {
75 title: newTitle(),
76 done: false,
77 })
78 setTitle('')
79 })
80 }
81
82 // setTimeout(() => {
83 // setTodos(
84 // 'values',
85 // 0,
86 // reconcile({
87 // title: 'Learn Solid-JS',
88 // done: false,
89 // [Math.random() + '']: 'hello',
90 // }),
91 // )
92 // }, 1000)
93
94 return (
95 <>
96 <h3>{props.title}</h3>
97 <s.Show when={true} keyed>
98 {v => {
99 s.createRoot(d => {
100 s.createEffect(newTitle, undefined, {name: 'newTitle effect'})
101 })
102 return (
103 <form onSubmit={addTodo}>
104 <input
105 placeholder="enter todo and click +"

Callers

nothing calls this directly

Calls 2

createLocalStoreFunction · 0.85
newTitleFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…