MCPcopy Create free account
hub / github.com/TanStack/db / handleSubmit

Function handleSubmit

examples/solid/todo/src/components/TodoApp.tsx:104–116  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

102
103 const handleSubmit: JSX.CustomEventHandlersCamelCase<HTMLFormElement>[`onSubmit`] =
104 (e) => {
105 e.preventDefault()
106 if (!newTodo().trim()) return
107
108 props.todoCollection.insert({
109 text: newTodo(),
110 completed: false,
111 id: Math.round(Math.random() * 1000000),
112 created_at: new Date(),
113 updated_at: new Date(),
114 })
115 setNewTodo(``)
116 }
117
118 const activeTodos = props.todos.filter((todo) => !todo.completed)
119 const completedTodos = props.todos.filter((todo) => todo.completed)

Callers

nothing calls this directly

Calls 1

insertMethod · 0.45

Tested by

no test coverage detected