Skip to content

Commit d22b0cb

Browse files
Remove if from first use Effect
You can use && operator instead of if statement.
1 parent 0fcb547 commit d22b0cb

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/App.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ const App = () => {
1313
useEffect(() => {
1414
const savedNotes = JSON.parse(localStorage.getItem("react-notes-app-data"));
1515

16-
if (savedNotes) {
17-
setNotes(savedNotes);
18-
}
16+
savedNotes && setNotes(savedNotes);
1917
}, []); // empty array runs only on first load
2018

2119
useEffect(() => {

0 commit comments

Comments
 (0)