feat: add link input modal#122
Merged
wendyyuchensun merged 3 commits intocoseeing:mainfrom Apr 5, 2026
Merged
Conversation
jamliaoo
reviewed
Apr 5, 2026
src/components/link-input-modal.js
Outdated
Comment on lines
+13
to
+32
| const resetForm = useCallback(() => { | ||
| setDisplay(''); | ||
| setTitle(''); | ||
| setUrl(''); | ||
| setOpenInNewTab(true); | ||
| }, []); | ||
|
|
||
| const handleClose = useCallback(() => { | ||
| resetForm(); | ||
| onClose(); | ||
| }, [resetForm, onClose]); | ||
|
|
||
| const handleConfirm = useCallback(() => { | ||
| if (!display.trim() || !url.trim()) return; | ||
| const prefix = openInNewTab ? '@' : ''; | ||
| const titlePart = title.trim() ? `[[${title.trim()}]]` : ''; | ||
| const markdown = `${prefix}[${display.trim()}]${titlePart}(${url.trim()})`; | ||
| onConfirm(markdown); | ||
| handleClose(); | ||
| }, [display, title, url, openInNewTab, onConfirm, handleClose]); |
Collaborator
There was a problem hiding this comment.
這三個 function 好像不需要包 useCallback 嗎~?
就我所知好像以下情境比較需要:
- 傳給 React.memo 包裝的子元件,避免不必要的 re-render
- 作為其他 hook(如 useEffect)的依賴
jamliaoo
approved these changes
Apr 5, 2026
e0c5b72 to
4dcd072
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Solve #116 .
Figma: https://www.figma.com/design/7gvWa3UzE4w5Kloy2CYGTb/%E5%B7%A5%E5%85%B7%E9%A1%9E%E8%A8%AD%E8%A8%88%E7%B3%BB%E7%B5%B1_2025?node-id=615-7832&t=sCSmmXUAs1eMFe9D-0
Demo