Skip to content
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 post #906

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ValeraViachalo
Copy link


type Props = {
selectedPost: Post;
setComments: (value: Comment[] | { (prev: Comment[]): Comment[] }) => void,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's make it shorter
look here

setFormShowed,
}) => {
const [comments, setComments] = useState<Comment[]>([]);
const [isLoading, setLoading] = useState(false);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const [isLoading, setLoading] = useState(false);
const [isLoading, setIsLoading] = useState(false);

setSelectedUser,
setSelectedPost,
}) => {
const [isActive, setActive] = useState(false);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const [isActive, setActive] = useState(false);
const [isActive, setIsActive] = useState(false);

Copy link

@anastasiia-tilikina anastasiia-tilikina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost done!

let's just figure out with types

@@ -8,7 +8,7 @@ import { addComments } from '../../services/comments';

type Props = {
selectedPost: Post;
setComments: (value: Comment[] | { (prev: Comment[]): Comment[] }) => void,
setComments: (value: Comment[] | ((prev: Comment[]) => Comment[])) => void;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

read provided link once more here the correct answer

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like that?
setComments: React.Dispatch<React.SetStateAction<Comment[]>>;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like that? setComments: React.Dispatch<React.SetStateAction<Comment[]>>;
yes, it is more correct type. use in such cases in next tasks

Copy link

@VitaliyBondarenko1982 VitaliyBondarenko1982 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@@ -8,7 +8,7 @@ import { addComments } from '../../services/comments';

type Props = {
selectedPost: Post;
setComments: (value: Comment[] | { (prev: Comment[]): Comment[] }) => void,
setComments: (value: Comment[] | ((prev: Comment[]) => Comment[])) => void;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like that? setComments: React.Dispatch<React.SetStateAction<Comment[]>>;
yes, it is more correct type. use in such cases in next tasks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants