Skip to content

Commit

Permalink
fixed issue with equality in props, moved to underscore
Browse files Browse the repository at this point in the history
  • Loading branch information
srclosson committed Sep 22, 2023
1 parent 934a4dc commit ec9aebd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "grafana-div-panel",
"version": "1.2.1",
"version": "1.2.2",
"description": "Create your own panel with html + css and javascript",
"scripts": {
"build": "webpack -c ./.config/webpack/webpack.config.ts --env production",
Expand Down Expand Up @@ -34,6 +34,7 @@
"@types/prop-types": "15.7.5",
"@types/react": "18.2.22",
"@cypress/request": "3.0.0",
"@types/underscore": "^1.11.9",
"acorn": "8.8.2",
"console-feed": "3.5.0",
"copy-webpack-plugin": "^11.0.0",
Expand Down Expand Up @@ -67,6 +68,7 @@
"typescript": "4.8.4",
"webpack": "^5.86.0",
"webpack-cli": "^5.1.4",
"underscore": "^1.13.6",
"webpack-livereload-plugin": "^3.0.2"
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions src/divPanelChild.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { Component } from 'react';
import * as functions from 'utils/functions';
import { DivPanelChildProps, divStyle } from './types';
import { register, compile } from 'utils/handlebars';
import { isEqual } from 'underscore';

interface State {
ref: HTMLDivElement | null;
Expand All @@ -19,8 +20,7 @@ export class DivPanelChild extends Component<DivPanelChildProps, State> {

shouldComponentUpdate = (prevProps: DivPanelChildProps, prevState: State): boolean => {
const truth =
((typeof prevProps !== "undefined" && typeof this.props !== "undefined") &&
(JSON.stringify(prevProps) !== JSON.stringify(this.props))) ||
isEqual(prevProps, this.props) ||
prevProps.data.state === 'Done' ||
prevProps.data.state === 'Streaming';
return truth;
Expand Down
15 changes: 10 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2943,6 +2943,11 @@
resolved "https://registry.yarnpkg.com/@types/tough-cookie/-/tough-cookie-4.0.3.tgz#3d06b6769518450871fbc40770b7586334bdfd90"
integrity sha512-THo502dA5PzG/sfQH+42Lw3fvmYkceefOspdCwpHRul8ik2Jv1K8I5OZz1AT3/rs46kwgMCe9bSBmDLYkkOMGg==

"@types/underscore@^1.11.9":
version "1.11.9"
resolved "https://registry.yarnpkg.com/@types/underscore/-/underscore-1.11.9.tgz#76a071d27e544e422dbf00f956818b1057f377b2"
integrity sha512-M63wKUdsjDFUfyFt1TCUZHGFk9KDAa5JP0adNUErbm0U45Lr06HtANdYRP+GyleEopEoZ4UyBcdAC5TnW4Uz2w==

"@types/[email protected]":
version "9.0.1"
resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-9.0.1.tgz#98586dc36aee8dacc98cc396dbca8d0429647aa6"
Expand Down Expand Up @@ -10122,16 +10127,16 @@ unbox-primitive@^1.0.2:
has-symbols "^1.0.3"
which-boxed-primitive "^1.0.2"

[email protected]:
version "1.12.1"
resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.12.1.tgz#7bb8cc9b3d397e201cf8553336d262544ead829e"
integrity sha512-hEQt0+ZLDVUMhebKxL4x1BTtDY7bavVofhZ9KZ4aI26X9SRaE+Y3m83XUL1UP2jn8ynjndwCCpEHdUG+9pP1Tw==

[email protected]:
version "1.7.0"
resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.7.0.tgz#6bbaf0877500d36be34ecaa584e0db9fef035209"
integrity sha512-cp0oQQyZhUM1kpJDLdGO1jPZHgS/MpzoWYfe9+CM2h/QGDZlqwT2T3YGukuBdaNJ/CAPoeyAZRRHz8JFo176vA==

underscore@^1.13.6:
version "1.13.6"
resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.13.6.tgz#04786a1f589dc6c09f761fc5f45b89e935136441"
integrity sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A==

unicode-canonical-property-names-ecmascript@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz#301acdc525631670d39f6146e0e77ff6bbdebddc"
Expand Down

0 comments on commit ec9aebd

Please sign in to comment.