Skip to content

Commit

Permalink
fix re-rendering when no parameters have changed (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
valya authored Oct 16, 2020
1 parent 80fca9b commit 9ccdbbf
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ function ReactWordCloud({
words,
...rest
}) {
const mergedCallbacks = { ...defaultCallbacks, ...callbacks };
const mergedOptions = { ...defaultOptions, ...options };

const [ref, selection, size] = useResponsiveSvgSelection(
minSize,
initialSize,
Expand All @@ -48,6 +45,9 @@ function ReactWordCloud({

useEffect(() => {
if (selection) {
const mergedCallbacks = { ...defaultCallbacks, ...callbacks };
const mergedOptions = { ...defaultOptions, ...options };

render.current({
callbacks: mergedCallbacks,
maxWords,
Expand All @@ -57,7 +57,7 @@ function ReactWordCloud({
words,
});
}
}, [maxWords, mergedCallbacks, mergedOptions, selection, size, words]);
}, [maxWords, callbacks, options, selection, size, words]);

return <div ref={ref} style={{ height: '100%', width: '100%' }} {...rest} />;
}
Expand Down

0 comments on commit 9ccdbbf

Please sign in to comment.