From 9ccdbbfb4fc60a70a895a4ffa59050a864eeccd8 Mon Sep 17 00:00:00 2001 From: Valya <68596159+valya@users.noreply.github.com> Date: Fri, 16 Oct 2020 18:57:26 +0100 Subject: [PATCH] fix re-rendering when no parameters have changed (#68) --- src/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index 2a16a34..e2aafbb 100644 --- a/src/index.js +++ b/src/index.js @@ -35,9 +35,6 @@ function ReactWordCloud({ words, ...rest }) { - const mergedCallbacks = { ...defaultCallbacks, ...callbacks }; - const mergedOptions = { ...defaultOptions, ...options }; - const [ref, selection, size] = useResponsiveSvgSelection( minSize, initialSize, @@ -48,6 +45,9 @@ function ReactWordCloud({ useEffect(() => { if (selection) { + const mergedCallbacks = { ...defaultCallbacks, ...callbacks }; + const mergedOptions = { ...defaultOptions, ...options }; + render.current({ callbacks: mergedCallbacks, maxWords, @@ -57,7 +57,7 @@ function ReactWordCloud({ words, }); } - }, [maxWords, mergedCallbacks, mergedOptions, selection, size, words]); + }, [maxWords, callbacks, options, selection, size, words]); return
; }