-
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 post #906
base: master
Are you sure you want to change the base?
Dynamic list of post #906
Conversation
|
||
type Props = { | ||
selectedPost: Post; | ||
setComments: (value: Comment[] | { (prev: Comment[]): Comment[] }) => void, |
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.
let's make it shorter
look here
setFormShowed, | ||
}) => { | ||
const [comments, setComments] = useState<Comment[]>([]); | ||
const [isLoading, setLoading] = 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.
const [isLoading, setLoading] = useState(false); | |
const [isLoading, setIsLoading] = useState(false); |
setSelectedUser, | ||
setSelectedPost, | ||
}) => { | ||
const [isActive, setActive] = 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.
const [isActive, setActive] = useState(false); | |
const [isActive, setIsActive] = 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.
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; |
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.
read provided link once more here the correct answer
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.
like that?
setComments: React.Dispatch<React.SetStateAction<Comment[]>>;
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.
like that?
setComments: React.Dispatch<React.SetStateAction<Comment[]>>;
yes, it is more correct type. use in such cases in next tasks
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.
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; |
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.
like that?
setComments: React.Dispatch<React.SetStateAction<Comment[]>>;
yes, it is more correct type. use in such cases in next tasks
LINK