import React, { useRef, FC, useState } from 'react'; import './index.less'; import { useAppSelector, useAppDispatch } from 'store'; import { addTodo, getTodoList } from 'store/todos'; let id = 2; const Demo: FC = () => { const { todos } = useAppSelector(state => state); const dispatch = useAppDispatch(); const inputRef = useRef(null); const [loading, setLoading] = useState(false); const onAdd = () => { if (!inputRef.current) return; const value = inputRef.current.value; if (value) { dispatch( addTodo({ text: value, id: ++id, completed: false }) ); inputRef.current.value = ''; } else { inputRef.current.focus(); } }; const onLoadMore = async () => { setLoading(true); await dispatch(getTodoList(1000)); setLoading(false); }; return (

This is Home Page.



{loading ? ( Loading... ) : ( )}
); }; export default Demo;