Skip to content

Commit 8c796c8

Browse files
committed
fix some small issues with prompt
1 parent 9ef0110 commit 8c796c8

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

tsunami/prompts/system.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ Helper functions:
222222
- `vdom.Ternary[T any](cond bool, trueRtn T, falseRtn T) T` - Type-safe ternary operation, returns trueRtn if condition is true, falseRtn otherwise
223223
- `vdom.ForEach[T any](items []T, fn func(T, int) any) []any` - Maps over items with index, function receives item and index
224224
- `vdom.Classes(classes ...any) string` - Combines multiple class values into a single space-separated string, similar to JavaScript clsx library (accepts string, []string, and map[string]bool params)
225+
- `app.DeepCopy[T any](value T) T` - Creates a deep copy of slices, maps, and other complex types for safe state updates
225226

226227
- The vdom.If and vdom.IfElse functions can be used for both conditional rendering of elements, conditional classes, and conditional props.
227228
- For vdom.If and vdom.IfElse, always follow the pattern of condition first (bool), then value(s).
@@ -534,7 +535,7 @@ Event handlers follow React patterns while providing additional type safety and
534535

535536
```go
536537
var MyComponent = app.DefineComponent("MyComponent",
537-
func(props MyProps) any {
538+
func(props struct{}) any {
538539
// UseLocal: returns Atom[T] with Get(), Set(), and SetFn() methods
539540
count := app.UseLocal(0) // Initial value of 0
540541
items := app.UseLocal([]string{}) // Initial value of empty slice
@@ -556,7 +557,10 @@ var MyComponent = app.DefineComponent("MyComponent",
556557

557558
addItem := func(item string) {
558559
// When updating slices/maps, create new value
559-
items.Set(append([]string{}, currentItems..., item))
560+
items.SetFn(func(current []string) []string {
561+
newItems := app.DeepCopy(current)
562+
return append(newItems, item)
563+
})
560564
}
561565

562566
// Refs for values that persist between renders but don't trigger updates

0 commit comments

Comments
 (0)