-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Constant for the querystring key for selected movie ID
I'd like to use enums here. I think an enum like ``` enum QuerystringKeys { SelectedMovieId = 'selected', ... } ``` provides much better editor hinting for the developer. Adding them to `includes` in tsconfig means they don't need to be imported to be used as a variable ``` useQuerystring(QuerystringKeys.SelectedMovieId); ``` but I ran into this issue evanw/esbuild#3359
- Loading branch information
1 parent
3f0c789
commit cb96f5a
Showing
6 changed files
with
29 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
export const API_ORIGIN = 'http://localhost:3000'; | ||
|
||
export const SORT_KEYS = ['asc', 'desc']; | ||
|
||
export const SELECTED_MOVIE_ID_QUERYSTRING_KEY = 'selected'; |
This file contains 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 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 |
---|---|---|
@@ -1,16 +1,16 @@ | ||
import { useEffect, useState } from 'react'; | ||
|
||
export const useTemporaryMessage = (timeout = 4000) => { | ||
const [temporaryMessage, setTemporaryMessage] = useState(''); | ||
const [message, setMessage] = useState(''); | ||
|
||
useEffect(() => { | ||
const timer = setTimeout(() => { | ||
if (temporaryMessage) { | ||
setTemporaryMessage(''); | ||
if (message) { | ||
setMessage(''); | ||
} | ||
}, timeout); | ||
return () => clearTimeout(timer); | ||
}, [temporaryMessage]); | ||
}, [message]); | ||
|
||
return { temporaryMessage, setTemporaryMessage }; | ||
return { message, setMessage }; | ||
}; |