Skip to content

Commit

Permalink
fix: save to localStorage only when state changes
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich authored Jun 26, 2019
2 parents b937296 + 0811b2b commit ba6d375
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/useLocalStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const useLocalStorage = <T>(key: string, initialValue?: T, raw?: boolean): [T, (
// If user is in private mode or has storage restriction
// localStorage can throw. Also JSON.stringify can throw.
}
});
}, [state]);

return [state, setState];
};
Expand Down

0 comments on commit ba6d375

Please sign in to comment.