-
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
Dynamic list of posts #920
base: master
Are you sure you want to change the base?
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.
provide the demo link in the PR description
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.
Please check comments.
src/App.tsx
Outdated
handleDropdown={setIsDropdownOpen} | ||
selectedUser={selectedUser} | ||
handleSelectedUser={setSelectedUser} | ||
// setSelectedPost={setPosts} |
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.
remove commented code. check other places
src/components/NewCommentForm.tsx
Outdated
const [commentName, setCommentName] = useState(''); | ||
const [commentEmail, setCommentEmail] = useState(''); | ||
const [commentText, setCommentText] = 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.
const [commentName, setCommentName] = useState(''); | |
const [commentEmail, setCommentEmail] = useState(''); | |
const [commentText, setCommentText] = useState(''); | |
const [newComment, setNewComment] = useState({ | |
name: '', | |
email: '', | |
text: '', | |
}); |
suggest to make one state for all inputs and change proper field with event.target.name in one change handler instead three (key in state object should be the same as name attribute in input)
somethign like that
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const { value, name } = event.target;
setNewComment(prevNewComment => ({
...prevNewComment,
[name]: value,
}) );
};
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
https://dimkamg21.github.io/react_dynamic-list-of-posts/