mirror of
https://github.com/gurnec/removeddit.git
synced 2026-03-11 08:54:27 +00:00
Add eslint-plugin-react-hooks and fix a related bug
To reproduce the bug with the older code, visit https://www.unddit.com/r/space/comments/y8ul7n/_/it2cz6o/ and then click the Parent link on the top-most comment. Installing eslint-plugin-react-hooks hopefully prevents future related bugs.
This commit is contained in:
parent
529162bec0
commit
7c935ab666
6 changed files with 28 additions and 13 deletions
|
|
@ -5,7 +5,8 @@
|
|||
},
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:react/recommended"
|
||||
"plugin:react/recommended",
|
||||
"plugin:react-hooks/recommended"
|
||||
],
|
||||
"overrides": [
|
||||
],
|
||||
|
|
|
|||
20
package-lock.json
generated
20
package-lock.json
generated
|
|
@ -30,6 +30,7 @@
|
|||
"css-toggle-switch": "^4.1.0",
|
||||
"eslint": "^8.25.0",
|
||||
"eslint-plugin-react": "^7.31.10",
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
"sass": "^1.55.0",
|
||||
"webpack": "^5.74.0",
|
||||
"webpack-cli": "^4.10.0",
|
||||
|
|
@ -3471,6 +3472,18 @@
|
|||
"eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-react-hooks": {
|
||||
"version": "4.6.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.0.tgz",
|
||||
"integrity": "sha512-oFc7Itz9Qxh2x4gNHStv3BqJq54ExXmfC+a1NjAta66IAN87Wu0R/QArgIS9qKzX3dXKPI9H5crl9QchNMY9+g==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-react/node_modules/doctrine": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz",
|
||||
|
|
@ -12604,6 +12617,13 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"eslint-plugin-react-hooks": {
|
||||
"version": "4.6.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.0.tgz",
|
||||
"integrity": "sha512-oFc7Itz9Qxh2x4gNHStv3BqJq54ExXmfC+a1NjAta66IAN87Wu0R/QArgIS9qKzX3dXKPI9H5crl9QchNMY9+g==",
|
||||
"dev": true,
|
||||
"requires": {}
|
||||
},
|
||||
"eslint-scope": {
|
||||
"version": "5.1.1",
|
||||
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz",
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@
|
|||
"css-toggle-switch": "^4.1.0",
|
||||
"eslint": "^8.25.0",
|
||||
"eslint-plugin-react": "^7.31.10",
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
"sass": "^1.55.0",
|
||||
"webpack": "^5.74.0",
|
||||
"webpack-cli": "^4.10.0",
|
||||
|
|
|
|||
|
|
@ -75,11 +75,8 @@ const Post = (props) => {
|
|||
}
|
||||
}
|
||||
|
||||
let editedMode, setEditedMode
|
||||
if (innerHTML[editedModes.rich])
|
||||
[editedMode, setEditedMode] = useState(editedModes.rich)
|
||||
else
|
||||
editedMode = editedModes.orig
|
||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||
const [editedMode, setEditedMode] = useState(innerHTML[editedModes.rich] ? editedModes.rich : editedModes.orig)
|
||||
|
||||
const totalComments = <div className='total-comments'>
|
||||
<Link to={props.permalink} replace={props.isLocFullPost}>{props.num_comments} comments</Link>
|
||||
|
|
|
|||
|
|
@ -45,11 +45,7 @@ const Comment = (props) => {
|
|||
}
|
||||
|
||||
const [collapsed, setCollapsed] = useState(false)
|
||||
let editedMode, setEditedMode
|
||||
if (innerHTML[editedModes.rich])
|
||||
[editedMode, setEditedMode] = useState(editedModes.rich)
|
||||
else
|
||||
editedMode = editedModes.orig
|
||||
const [editedMode, setEditedMode] = useState(innerHTML[editedModes.rich] ? editedModes.rich : editedModes.orig)
|
||||
const permalink = `/r/${props.subreddit}/comments/${props.link_id}/_/${props.id}/`
|
||||
const parentlink = props.parent_id == props.link_id ? undefined : (
|
||||
props.depth == 0 ?
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import React, { useState } from 'react'
|
||||
import {connect, sort, filter, minCommentsLimit, maxCommentsLimit, constrainMaxComments} from '../../state'
|
||||
|
||||
const sortBy = props => {
|
||||
const SortBy = props => {
|
||||
// The current value of the field; it'll be later saved after an onBlur event
|
||||
const [maxCommentsField, setMaxCommentsField] = useState(props.global.maxComments)
|
||||
const isFirefox = typeof InstallTrigger !== 'undefined'
|
||||
|
|
@ -57,4 +57,4 @@ const sortBy = props => {
|
|||
)
|
||||
}
|
||||
|
||||
export default connect(sortBy)
|
||||
export default connect(SortBy)
|
||||
|
|
|
|||
Loading…
Reference in a new issue