From d22b0cbec266008532a928e3b8c008f6fd4d366f Mon Sep 17 00:00:00 2001 From: Kamran Date: Tue, 16 Aug 2022 14:31:31 +0500 Subject: [PATCH] Remove if from first use Effect You can use && operator instead of if statement. --- src/App.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/App.js b/src/App.js index c3b673e..0a5cc5f 100644 --- a/src/App.js +++ b/src/App.js @@ -13,9 +13,7 @@ const App = () => { useEffect(() => { const savedNotes = JSON.parse(localStorage.getItem("react-notes-app-data")); - if (savedNotes) { - setNotes(savedNotes); - } + savedNotes && setNotes(savedNotes); }, []); // empty array runs only on first load useEffect(() => {