import { atom, Atom, useAtom } from "jotai"; import { useState } from "react"; import { Button, Form, ListGroup } from "react-bootstrap"; import Person, { IPerson } from "./Person"; export interface Props { splitBetweenAtom: Atom[]>; } export default function SplitBetween({ splitBetweenAtom }: Props) { const [splitBetween, setSplitBetween] = useAtom(splitBetweenAtom); const [input, setInput] = useState(""); const [editing, setEditing] = useState(false); const startEditing = (_) => { setInput(""); setEditing(true); }; const addPerson = (e) => { e.preventDefault(); const person = { name: atom(input) }; setSplitBetween([...splitBetween, atom(person)]); setEditing(false); }; return (
Split between ({splitBetween.length}): {splitBetween.map((a, i) => ( ))}
); }