todoitem.rs 704 B

1234567891011121314151617181920212223242526272829
  1. use super::state::TODOS;
  2. use crate::recoil::use_atom_family;
  3. use dioxus_core::prelude::*;
  4. #[derive(PartialEq, Props)]
  5. pub struct TodoEntryProps {
  6. id: uuid::Uuid,
  7. }
  8. pub fn TodoEntry(cx: Context, props: &TodoEntryProps) -> DomTree {
  9. let (is_editing, set_is_editing) = use_state(cx, || false);
  10. let todo = use_atom_family(&cx, &TODOS, cx.id);
  11. cx.render(rsx! (
  12. li {
  13. "{todo.id}"
  14. input {
  15. class: "toggle"
  16. type: "checkbox"
  17. "{todo.checked}"
  18. }
  19. {is_editing.then(|| rsx!(
  20. input {
  21. value: "{todo.contents}"
  22. }
  23. ))}
  24. }
  25. ))
  26. }