-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Implement useReducer for commentFormsVisibility #9862
Implement useReducer for commentFormsVisibility #9862
Conversation
/* eslint-disable complexity */ | ||
import { makeDeepCopy } from "./helpers"; | ||
|
||
const reducer = (state, action) => { |
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.
Function reducer
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
/* eslint-disable complexity */ | ||
import { makeDeepCopy } from "./helpers"; | ||
|
||
const reducer = (state, action) => { |
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.
Function reducer
has 47 lines of code (exceeds 25 allowed). Consider refactoring.
@@ -0,0 +1,58 @@ | |||
/* eslint-disable complexity */ | |||
import { makeDeepCopy } from "./helpers"; |
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.
Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
Codecov Report
@@ Coverage Diff @@
## main #9862 +/- ##
=======================================
Coverage ? 82.09%
=======================================
Files ? 98
Lines ? 5942
Branches ? 0
=======================================
Hits ? 4878
Misses ? 1064
Partials ? 0 |
Code Climate has analyzed commit 0ba49ac and detected 0 issues on this pull request. View more on Code Climate. |
Looks great, @noi5e !!!! |
* implement useReducer for comment state management publiclab#9365 * rename commentFormToggleState to commentFormsVisibility publiclab#9365 * convert commentFormsVisibility state management to useReducer publiclab#9365 * create reducer action for hiding comment form publiclab#9365
* implement useReducer for comment state management publiclab#9365 * rename commentFormToggleState to commentFormsVisibility publiclab#9365 * convert commentFormsVisibility state management to useReducer publiclab#9365 * create reducer action for hiding comment form publiclab#9365
* implement useReducer for comment state management publiclab#9365 * rename commentFormToggleState to commentFormsVisibility publiclab#9365 * convert commentFormsVisibility state management to useReducer publiclab#9365 * create reducer action for hiding comment form publiclab#9365
Part of a React rewrite of the commenting system, see #9365 for more context.
This PR is a follow-up to #9801. In that PR, I started to implement React's
useReducer
to handle state management, which is becoming more complex.Basically, #9801 converted
state
'scomments
object touseReducer
. This PR convertsstate
'scommentFormsVisibility
touseReducer
.commentFormsVisibility
is a bit of data in statethat models whether or not an edit/reply comment form is visible on the page(This issue is part of the larger Comment Editor Overhaul Project with Outreachy. Refer to Planning Issue #9069 for more context)