-
-
Notifications
You must be signed in to change notification settings - Fork 507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Better align REPL examples for comparison #1164
Conversation
return ( | ||
<form onSubmit={addTodo}> | ||
<input type="text" value={newItem.value} onInput={onInput} /> | ||
<button onClick={addTodo}>Add</button> | ||
<ul> | ||
{todos.value.map((todo, index) => ( | ||
<li> | ||
<label> | ||
<input | ||
type="checkbox" | ||
checked={todo.completed} | ||
onInput={() => { | ||
todo.completed = !todo.completed; | ||
todos.value = [...todos.value]; | ||
}} | ||
/> | ||
{todo.completed ? <s>{todo.text}</s> : todo.text} | ||
</label>{' '} | ||
<button onClick={() => removeTodo(index)}>❌</button> | ||
</li> | ||
))} | ||
</ul> | ||
<p>Completed count: {completedCount.value}</p> | ||
</form> | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The updated example doesn't work. Try removing a todo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to work just fine for me? What issue are you seeing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange, I can't reproduce. Try refreshing whilst clearing the cache, you might have something left over? Else, I'll look into it when I can.
Peek.2024-08-31.23-41.mp4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yep, forgot type="button"
as per usual.
Good catch!
We have a couple examples that beg comparison (
counter
vscounter-htm
,todo-list
vstodo-list-signals
) but have implemented them rather differently so that the comparison mostly falls flat -- it's very much an apples-to-oranges comparison.While that's not inherently a problem, I think it's better to more closely align these examples so that we can better show newer users the direct translation of some (very basic) concepts of these APIs we offer.
I might go pick up a list of other common examples that other framework show, might be nice to flesh this list out further.
I also ran all the examples through Prettier, some were a bit inconsistent