⛳
配列をオブジェクトにする
1行のインプットフォームを2行にしたい
- const [memoList,setMemoList] = useState(['aa', 'bb', 'cc', 'dd']);
+ export type Memo = {
+ title: string
+ body: string
+ }
+ const [memoList,setMemoList] = useState<Memo[]>([{
+ title:'',
+ body:'',
+ }]);
const onClickAdd = () => {
if (inputText === '')return;
- const newTasks = [...memoList, inputText];
+ const newTasks = [...memoList, { title: inputText, body: inputText }];
setMemoList(newTasks);
setInputText('');
};
Discussion