-
Notifications
You must be signed in to change notification settings - Fork 243
feat: memoriser certains champs dans le localstorage #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| const localStorage = window.localStorage || { | ||
| getItem: () => null, | ||
| setItem: () => undefined, | ||
| } | ||
|
|
||
| export function getPreviousFormValue(name) { | ||
| return localStorage.getItem(`form-value-${name}`) | ||
| } | ||
|
|
||
| export function setPreviousFormValue(name, value) { | ||
| localStorage.setItem(`form-value-${name}`, value) | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Je ne suis pas un expert de JavaScript donc je peux me tromper, mais est-ce que ce point-virgule n'est pas en trop ?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sans le point virgule, javascript croit que le
[est l'accès à l'élément d'un tableau qui serait retourné par la ligne au dessuspar exemple
est interprété comme
et throw une erreur "cannot read property '1' of undefined"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ce ne serait pas plus logique de mettre les trailing semicolons... à la fin de la ligne ? Ou ESLint l'empêche ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Y a tout un débat à ce sujet de puis des années https://www.google.com/search?q=javascript+semicolon+or+not voir également https://prettier.io/docs/en/rationale.html#semicolons
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://dev.to/adriennemiller/semicolons-in-javascript-to-use-or-not-to-use-2nli
TLDR: en gros, au moment de compiler le code, JavaScript détermine les endroits où il pense qu'il aurait dû y avoir des points-virgule. Sauf qu'il y a plein de cas où il se foire. Dans ces conditions, il me semble plus judicieux de mettre les points-virgule partout pour éviter les erreurs.
Bonus : ça rend le code plus accessible à ceux qui sont moins habitués aux subtilité du langage, et ça réduit un peu la complexité cognitive du code :)
Cela dit, il me semble plus sage de faire dans le cadre d'une autre issue pour éviter du bruit inutile sur cette PR (et ça sera plus propice aux discussions) :)