From 0f4429b8831482db83ac262ec16e35ed10ff25ce Mon Sep 17 00:00:00 2001 From: joost-stessens <122776799+joost-stessens@users.noreply.github.com> Date: Mon, 9 Sep 2024 17:20:11 +0200 Subject: [PATCH] Fix: avoid inititializing RGL on each render (prevents rerenders) --- drag-n-drop-chart-library/src/App.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drag-n-drop-chart-library/src/App.js b/drag-n-drop-chart-library/src/App.js index 4a4cce3..aad6b3f 100644 --- a/drag-n-drop-chart-library/src/App.js +++ b/drag-n-drop-chart-library/src/App.js @@ -14,6 +14,9 @@ import userflow from "userflow.js"; userflow.init("ct_65z5oczamna45bveai47cpcbpe"); userflow.identifyAnonymous(); +// initialize RGL +const ReactGridLayout = WidthProvider(RGL); + export default function App() { // initialize state const [open, setOpen] = React.useState(false); @@ -21,8 +24,6 @@ export default function App() { const [activeCharts, setActiveCharts] = React.useState( initialState.activeCharts ); - // initialize RGL - const ReactGridLayout = WidthProvider(RGL); // App functions const handleClearCharts = () => {