-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
solution #1044
base: master
Are you sure you want to change the base?
solution #1044
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work 👍
Left a few suggestions, check them
src/App.tsx
Outdated
const todos = useAppSelector(state => state.todos); | ||
const currentTodo = useAppSelector(state => state.currentTodo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to create selectors so you can reuse them
https://redux.js.org/usage/deriving-data-selectors
src/App.tsx
Outdated
const dispatch = useDispatch(); | ||
const todos = useAppSelector(state => state.todos); | ||
const currentTodo = useAppSelector(state => state.currentTodo); | ||
const [loader, setLoader] = useState(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Boolean variables should start from is
or has
src/components/TodoList/TodoList.tsx
Outdated
const filteredTodos = todos | ||
.filter(todo => { | ||
if (status === Status.Active) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Create a separate function and move it to utils/helpers folder
- if there are no query and status is all you don't need to filter at all
- also, you can try to do it in one filter
src/components/TodoList/TodoList.tsx
Outdated
|
||
<tbody> | ||
{filteredTodos.map(({ id, completed, title, userId }) => ( | ||
<tr key={id} data-cy="todo"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create a todo component
const dispatch = useDispatch(); | ||
const currentTodo = useAppSelector(state => state.currentTodo); | ||
const [user, setUser] = useState<User>(); | ||
const [loading, setLoading] = useState<boolean>(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same about naming
setLoading(true); | ||
if (currentTodo) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is no currentTodo
user will see infinite loader
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done 👍
DEMO LINK