-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Develop #2697
base: master
Are you sure you want to change the base?
Develop #2697
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 job
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.
Thank you for your hard work on this project! 🚀 While your code meets many of the task requirements, there are a few critical issues that need to be addressed before we can approve the pull request:
-
State and Dependency Management: The
useEffect
hook inTodoModal.tsx
should includetodo
as a dependency to ensure it runs correctly whentodo
changes. Additionally, the dependency array inApp.tsx
includesisLoad
, which may lead to unnecessary re-renders. If the effect is meant to run only once, consider using an empty array[]
. -
Naming Conventions: Several variable names do not follow common conventions, which can impact code readability and maintainability:
isLoad
should be renamed toisLoading
.isModalSee
should be renamed toisModalVisible
.qwerty
should be renamed tosearchQuery
.curentTodos
has a typo and should be corrected tocurrentTodos
, or better yet,filteredTodos
to reflect its purpose.
-
Code Simplification: Consider using optional chaining and logical operators to simplify your code. For example, using
todos?.map(...)
andselectedTodo?.id === todo.id && 'has-background-info-light'
can make your code more concise and easier to read.
Please address these issues to ensure the code is robust and maintainable. Once these changes are made, we can move forward with the approval. Keep up the great work, and don't hesitate to reach out if you have any questions! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review
button in the Reviewers tab.
src/App.tsx
Outdated
|
||
export const App: React.FC = () => { | ||
const [isLoad, setIsLoad] = useState(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 state variable isLoad
is not named according to common conventions. Consider renaming it to isLoading
for better readability and to follow the convention of using present participles for boolean state variables.
src/App.tsx
Outdated
|
||
export const App: React.FC = () => { | ||
const [isLoad, setIsLoad] = useState(true); | ||
const [isModalSee, setIsModalSee] = 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.
The state variable isModalSee
is not named according to common conventions. Consider renaming it to isModalVisible
for better readability and to follow the convention of using present participles for boolean state variables.
src/App.tsx
Outdated
setTimeout(() => { | ||
setIsLoad(false); | ||
}, 1000); | ||
}, [isLoad]); |
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 dependency array for the useEffect
hook includes isLoad
. This means the effect will run every time isLoad
changes, which might not be the intended behavior. If you want the effect to run only once when the component mounts, consider using an empty dependency array []
.
}; | ||
|
||
export const TodoFilter: React.FC<Props> = ({ setTodos }) => { | ||
const [qwerty, setQwerty] = useState(''); |
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 variable name qwerty
is not descriptive. Consider renaming it to something more meaningful, such as searchQuery
, to better convey its purpose.
|
||
useEffect(() => { | ||
getTodos().then(serverTodos => { | ||
let curentTodos: Todo[] | null = serverTodos.filter(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.
There is a typo in the variable name curentTodos
. It should be currentTodos
to correctly spell 'current'.
src/components/TodoList/TodoList.tsx
Outdated
</td> | ||
</tr> | ||
function mapTodos() { | ||
if (todos) { |
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.
Consider using optional chaining to simplify the check for todos
. For example, todos?.map(...)
can be used to handle the case where todos
is null
or undefined
.
src/components/TodoList/TodoList.tsx
Outdated
<tr | ||
data-cy="todo" | ||
className={ | ||
selectedTodo !== null |
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 conditional rendering logic for class names can be simplified using optional chaining and logical operators. For example, selectedTodo?.id === todo.id && 'has-background-info-light'
can be used to make the code more concise.
}; | ||
|
||
export const TodoModal: React.FC<Props> = ({ setVisible, todo, setTodo }) => { | ||
const [isLoad, setIsLoad] = useState(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 state variable isLoad
is not named according to common conventions. Consider renaming it to isLoading
for better readability and to follow the convention of using present participles for boolean state variables.
if (todo) { | ||
getUser(todo.userId).then(setUser); | ||
} | ||
}, []); |
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 useEffect
hook should include todo
as a dependency. This ensures that the effect runs whenever todo
changes, which is important for fetching the correct user data when a different todo is selected.
}, []); | ||
|
||
if (!todo) { | ||
return; |
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 return
statement here does not return any JSX or null, which may lead to unexpected behavior. Consider returning null
explicitly if the todo
is not available.
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.
Thank you for your submission! 🎉 Your code is generally well-structured and follows good practices, but there are a few areas that could be improved to enhance readability and maintainability:
-
State and Dependency Management:
- In
TodoModal.tsx
, consider addingtodo
to theuseEffect
dependency array to ensure it re-runs when thetodo
prop changes. This will allow the component to fetch the correct user data for the newtodo
. - In
App.tsx
, verify that theuseEffect
hook is intended to run only once with an empty dependency array, as it will not react to changes in any state or props.
- In
-
Naming Conventions:
- In
TodoFilter.tsx
, renaming the variableqwerty
tosearchQuery
would better reflect its purpose and improve code readability.
- In
-
Code Simplification:
- Consider using optional chaining when accessing properties of potentially null or undefined objects, such as
serverTodos?.filter(...)
,todos?.map(...)
, andselectedTodo?.id === todo.id && 'has-background-info-light'
.
- Consider using optional chaining when accessing properties of potentially null or undefined objects, such as
These changes will help make your code more robust and maintainable. Keep up the great work, and continue to learn from these suggestions to improve your coding skills! 🚀
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
useEffect(() => { | ||
setTimeout(() => { | ||
setIsLoading(false); | ||
}, 1000); | ||
}, []); |
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 useEffect
hook is set to run only once with an empty dependency array. Ensure this is the intended behavior, as it will not react to changes in any state or props.
todos={todos} | ||
selectedTodo={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.
Consider using optional chaining when accessing properties of potentially null or undefined objects, e.g., todos?.map(...)
and selectedTodo?.id === todo.id && 'has-background-info-light'
.
}; | ||
|
||
export const TodoFilter: React.FC<Props> = ({ setTodos }) => { | ||
const [qwerty, setQwerty] = useState(''); |
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.
Consider renaming qwerty
to searchQuery
to better reflect its purpose and improve code readability.
let currentTodos: Todo[] | null = serverTodos.filter(todo => | ||
todo.title.toLocaleLowerCase().includes(qwerty.toLocaleLowerCase()), | ||
); |
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.
Consider using optional chaining when accessing properties of potentially null or undefined objects, e.g., serverTodos?.filter(...)
.
useEffect(() => { | ||
setTimeout(() => { | ||
setIsLoading(false); | ||
}, 1000); | ||
|
||
if (todo) { | ||
getUser(todo.userId).then(setUser); | ||
} | ||
}, []); |
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.
Consider adding todo
to the dependency array of the useEffect
hook to ensure it re-runs when the todo
prop changes. This will allow the component to fetch the correct user data for the new todo
.
DEMO LINK