wip: parity document

This commit is contained in:
Jonathan Kelley committed 2021-05-26 11:22:44 -04:00
1 parent ee67654f58
commit ba975410f9
7 files changed
+115 -51

No files matched your search

+19 -4
View File
@@ -2,16 +2,22 @@ use std::collections::HashMap;
use dioxus_core::prelude::*;
use recoil::*;
use uuid::Uuid;
const TODOS: AtomFamily<&str, Todo> = |_| HashMap::new();
const TODOS: AtomFamily<Uuid, Todo> = |_| HashMap::new();
#[derive(PartialEq)]
struct Todo {
checked: bool,
title: String,
contents: String,
}
static App: FC<()> = |ctx, _| {
use_init_recoil_root(ctx);
let todos = use_recoil_family(ctx, &TODOS);
rsx! { in ctx,
div {
"Basic Todolist with AtomFamilies in Recoil.rs"
@@ -19,11 +25,20 @@ static App: FC<()> = |ctx, _| {
}
};
static Child: FC<()> = |ctx, _| {
// let todo = use_recoil_value(ctx, &TODOS);
#[derive(Props, PartialEq)]
struct ChildProps {
id: Uuid,
}
static Child: FC<ChildProps> = |ctx, props| {
let (todo, set_todo) = use_recoil_state(ctx, &TODOS.select(&props.id));
rsx! { in ctx,
div {
h1 {"{todo.title}"}
input { type: "checkbox", name: "scales", checked: "{todo.checked}" }
label { "{todo.contents}", for: "scales" }
p {"{todo.contents}"}
}
}
};
+2 -1
View File
@@ -18,8 +18,9 @@ const D_SELECTOR: SelectorFamilyBorrowed<i32, i32> = |api, key| -> &i32 {
};
static App: FC<()> = |ctx, _| {
let title = use_recoil_value(ctx, &C_SELECTOR);
use_init_recoil_root(ctx);
let title = use_recoil_value(ctx, &C_SELECTOR);
let title = "";
rsx! { in ctx,
div {