From 27e596e9163a67368174658978a296af5cb86d16 Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Thu, 26 Sep 2024 14:10:39 +0100 Subject: [PATCH] fix: react render error (#25227) Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> --- .eslintrc.js | 3 ++ ...n-ui-lemon-input-select--default--dark.png | Bin 1804 -> 1645 bytes ...-ui-lemon-input-select--default--light.png | Bin 1769 -> 1648 bytes frontend/src/queries/nodes/HogQLX/render.tsx | 45 ++++++++++-------- package.json | 1 + pnpm-lock.yaml | 12 +++++ 6 files changed, 40 insertions(+), 21 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index a2db223beff..403a38e4c43 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -42,6 +42,7 @@ module.exports = { }, plugins: [ 'react', + "react-hooks", 'cypress', '@typescript-eslint', 'compat', @@ -51,6 +52,8 @@ module.exports = { 'unused-imports', ], rules: { + "react-hooks/rules-of-hooks": "warn", + "react-hooks/exhaustive-deps": "warn", // PyCharm always adds curly braces, I guess vscode doesn't, PR reviewers often complain they are present on props that don't need them // let's save the humans time and let the machines do the work // "never" means if the prop does not need the curly braces, they will be removed/errored diff --git a/frontend/__snapshots__/lemon-ui-lemon-input-select--default--dark.png b/frontend/__snapshots__/lemon-ui-lemon-input-select--default--dark.png index 30d6848c0dcbf7228755ed513c8020bfe27f2127..ec8494f1cb6838e23a02e6aeb53912d15be4ed5c 100644 GIT binary patch delta 1615 zcmai!`&ZHj7{h96CeX@>@%bur#rB zMN&~&T1sAmnT~q4*-@q3u_Fo&_5Gtvj9-Ei;&6|J|+o zhFuF_1mp(Ha|2T0xh4Vt0PsLrO}bz!Wv`nf)B$zxPuCrN!4Rws)cx_bI=%kjHvrJK z>?WYc4bVMB5!-^{UpqIIhCZyLIFrj$Z>|M^duFuPsd3Of!pOCxD<@$DQSUZ^gn+^5 zX$}C85pw-oewAC}V0e7(03Rvk1^~c)4l!jgUCS!h!ijOybPxcNM)txBQ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W_#=C8zZAv{@1ux-|N?ZntxLEfLJ(X>wnaGdV15H5dgrGLl6XZ*`R;? z^Fu-iLo=J7*<4p!ZJOrD=#^wL*>t>lU6RZc8}O6?0M^s;1xZov-#^LGDDQ9t0)Fep z$S{n@pI&C!fTs)qux^$wNQ=$P&StsY))Tq6-#+@+zx~~650;h`7Z(XUf9LLGdq<}v zNsD{YG=Kg2k%r%Xi?nxirj8j1_yfg$m(w{rH`m>L`NqvLYy7v4zHzFhwYIiebh+-_ zooqYX9*xGVE-w|n7%UBlq9{r7z+m{w)gPA3cF8bn0>vyD$obe`*yWq(_egH;qH zk7rXwdGP9kw<8oq1%oA>o#$`e8jnPzuC9x{ef>6@Z6TnvB;aqgVR+2Nxf8xm-N&7@xSk&@wbUN(gb-9e;$7 zf^FME6=nbW@FQKp%&x~3b3VQqG>+v-;Mzd`d;QudJ+;5P$MgVc}qSXoU%_Wash5rq48e`B!GFFf7&UM;bVe zyLRoTiSdcykVIEBt7+QUt?{l47Y`l!^QKMNseSwU2KLod6>Q5FMX|7ON3bN&+t>f-KiAvW zfAB!vbI)xTMbYQWd$plHP=D-STiB8mMNyM#;fp&&QOwQtR_@uo%1Z(O0Bi9F{QG~o zx8E>~1N-+0JU=x(eWLkuRej(=+0f8Pj>q##{o$tL&B<{x0tylU0AvIdBme-&2(+#nshg7m0068TilTH~r!`H*c5MIvkVY)aYMMqXielrq zbSDD<02`OxW>b_nooGlT4b$X#KHd2M0Ki7X^SrL>i9~`XgvgRi2yr@{9LHfk2><}r z0Yy<9$2px&ViH-7{=VC{EXj7eT@ZNI>0%fxy#oM%$4l1@O;ckrW#KIl{{dzJ>sdeN RhXMcq002ovPDHLkV1kqMX{G=G diff --git a/frontend/__snapshots__/lemon-ui-lemon-input-select--default--light.png b/frontend/__snapshots__/lemon-ui-lemon-input-select--default--light.png index 115f6d83d8d7f3b54c217d879e4df2d1f44c4e07..5496b3c4488fac464a7442907ff7c5a4323ed8b8 100644 GIT binary patch delta 1618 zcmaJ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WdsS$cDd>^V5PJU&%foqH&%IQAb&2gi zYEG~La1p(XkEk) parseHogQLX(v)) } +function ViewRecordingModalButton({ sessionId }: { sessionId: string }): JSX.Element { + const { openSessionPlayer } = useActions(sessionPlayerModalLogic) + return ( + + } + data-attr="hog-ql-view-recording-button" + to={urls.replaySingle(sessionId)} + onClick={(e) => { + e.preventDefault() + if (sessionId) { + openSessionPlayer({ id: sessionId }) + } + }} + > + View recording + + + ) +} + export function renderHogQLX(value: any): JSX.Element { const object = parseHogQLX(value) @@ -44,27 +67,7 @@ export function renderHogQLX(value: any): JSX.Element { ) } else if (tag === 'RecordingButton') { const { sessionId, ...props } = rest - const { openSessionPlayer } = useActions(sessionPlayerModalLogic) - return ( - - } - data-attr="hog-ql-view-recording-button" - {...props} - to={urls.replaySingle(sessionId)} - onClick={(e) => { - e.preventDefault() - if (sessionId) { - openSessionPlayer({ id: sessionId }) - } - }} - > - View recording - - - ) + return } else if (tag === 'a') { const { href, source, target } = rest return ( diff --git a/package.json b/package.json index efe9a211b08..eb9b6649b64 100644 --- a/package.json +++ b/package.json @@ -267,6 +267,7 @@ "eslint-plugin-jest": "^28.6.0", "eslint-plugin-posthog": "link:./eslint-rules", "eslint-plugin-react": "^7.33.2", + "eslint-plugin-react-hooks": "^4.6.2", "eslint-plugin-simple-import-sort": "^10.0.0", "eslint-plugin-storybook": "^0.6.15", "eslint-plugin-unused-imports": "^3.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d2b9a78348d..559a67f7f03 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -614,6 +614,9 @@ devDependencies: eslint-plugin-react: specifier: ^7.33.2 version: 7.33.2(eslint@8.57.0) + eslint-plugin-react-hooks: + specifier: ^4.6.2 + version: 4.6.2(eslint@8.57.0) eslint-plugin-simple-import-sort: specifier: ^10.0.0 version: 10.0.0(eslint@8.57.0) @@ -12274,6 +12277,15 @@ packages: - typescript dev: true + /eslint-plugin-react-hooks@4.6.2(eslint@8.57.0): + resolution: {integrity: sha512-QzliNJq4GinDBcD8gPB5v0wh6g8q3SUi6EFF0x8N/BL9PoVs0atuGc47ozMRyOWAKdwaZ5OnbOEa3WR+dSGKuQ==} + engines: {node: '>=10'} + peerDependencies: + eslint: ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 + dependencies: + eslint: 8.57.0 + dev: true + /eslint-plugin-react@7.33.2(eslint@8.57.0): resolution: {integrity: sha512-73QQMKALArI8/7xGLNI/3LylrEYrlKZSb5C9+q3OtOewTnMQi5cT+aE9E41sLCmli3I9PGGmD1yiZydyo4FEPw==} engines: {node: '>=4'}