Skip to content

Commit

Permalink
fix: avoid re-render after 1st resize (#1669)
Browse files Browse the repository at this point in the history
  • Loading branch information
edoardo authored and janhenrikoverland committed Mar 31, 2021
1 parent e0a34e4 commit c77d8e4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/plugin/src/ChartPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const ChartPlugin = ({
}) => {
const canvasRef = useRef(undefined)
const prevStyle = useRef(style)
const prevRenderCounter = useRef(renderCounter)

const renderVisualization = useCallback(
animation => {
Expand Down Expand Up @@ -59,7 +60,10 @@ const ChartPlugin = ({
}, [visualization, responses, extraOptions])

useEffect(() => {
renderCounter !== null && renderVisualization(0)
if (renderCounter !== prevRenderCounter.current) {
renderVisualization(0)
prevRenderCounter.current = renderCounter
}

/* eslint-disable-next-line react-hooks/exhaustive-deps */
}, [renderCounter])
Expand Down

0 comments on commit c77d8e4

Please sign in to comment.