MCPcopy Create free account
hub / github.com/adobe/react-spectrum / BodyContent

Function BodyContent

examples/rsp-webpack-4/src/BodyContent.js:6–101  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4import JournalList from './JournalList';
5
6function BodyContent() {
7 //states for the To-Do list
8 const [list, setList] = useState([]);
9 const [value, setValue] = useState('');
10 const [completed, setCompleted] = useState([]);
11 const count = useRef(0);
12
13 //states for journal entries
14 const [rating, setRating] = useState('');
15 const [entryList, setEntryList] = useState([]);
16 const [description, setDescription] = useState('');
17 const countJournals = useRef(0);
18
19 const options = [
20 {id: 'Bad', name: 'Bad'},
21 {id: 'Okay', name: 'Okay'},
22 {id: 'Good', name: 'Good'},
23 {id: 'Great', name: 'Great'}
24 ];
25
26 //functions for the To-Do list
27 function handleSubmitToDo(e) {
28 e.preventDefault();
29
30 if (value.length > 0) {
31 setList(prevListArray => {
32 return [...prevListArray, {id: count.current, task: value}];
33 });
34
35 count.current = count.current + 1;
36 }
37 setValue(''); //clears text field on submit
38 }
39
40 function updateCompleted(complete) {
41 setCompleted(prevListArray => {
42 return [...prevListArray, {id: prevListArray.length, task: complete}];
43 });
44 }
45
46 function clearCompleted() {
47 setCompleted(() => {
48 return [];
49 });
50 }
51
52 //functions for journal entries
53 function handleSubmitJournals(e) {
54 e.preventDefault();
55
56 countJournals.current = countJournals.current + 1; //used to determine key for each item in the entryList array
57
58 setEntryList(prevListArray => {
59 return [
60 ...prevListArray,
61 {rate: rating, description: description, id: countJournals.current}
62 ];
63 });

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected