-
Notifications
You must be signed in to change notification settings - Fork 30
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
Lift comment state into discussion #10299
Conversation
Size Change: +471 B (0%) Total Size: 749 kB
ℹ️ View Unchanged
|
Hello 👋! When you're ready to run Chromatic, please apply the |
const [commentPageSize, setCommentPageSize] = useState<25 | 50 | 100>(); | ||
const [commentOrderBy, setCommentOrderBy] = useState< | ||
'newest' | 'oldest' | 'recommendations' | ||
>(); | ||
const [isExpanded, setIsExpanded] = useState<boolean>(false); | ||
const [commentCount, setCommentCount] = useState(0); |
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.
We have useCommentCount
for this specific purpose
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.
Ah, great, thanks Max! I didn't know that existed. I'll update the code to use that 👍
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.
I’ve actually discovered that commentCount
and topLevelCommentCount
cannot be conflated… the former relates to the number of comments, the latter to the number of threads!
Fix in #10477
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.
OH that's what this means!
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.
This effectively makes useDiscussion
only used in a single location. What are the plans for that custom hook?
Its a good question! I'm unsure how useful it is as a hook really. It returns |
b6dd805
to
855126e
Compare
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.
Unify all the states!
6f04d1b
to
5ed59fc
Compare
Seen on PROD (merged by @abeddow91 9 minutes and 32 seconds ago) Please check your changes! |
What does this change?
Lifts up comment state into the discussion component and out of comments. This means we only make one API call, and don't duplicate state.
It also removes the useDiscussion hook and implements the useCommentCount hook in discussion and discussion meta.
It also updates the comment stories to use manual fixture data.
Why?
We want discussion to have the source of truth for shared state. This makes the discussion app easier to read and reason about.
This is part of