pastebin: use more useCallback here to reduce re-rendering

This commit is contained in:
Peter Cai 2020-02-20 10:35:18 +08:00
parent e261f4957d
commit e3e3445b93
No known key found for this signature in database
GPG Key ID: 71F5FB4E4F3FD54F
1 changed files with 6 additions and 0 deletions

View File

@ -17,9 +17,15 @@ export default Pastebin = ->
onEditTextUpdate = (ev) ->
setText ev.target.value
# onEditTextUpdate depends on absolutely nothing for reading
onEditTextUpdate = useCallback onEditTextUpdate, []
paste = ->
# We force a single file name and mime type on web-pasted content
doPaste "web_paste.txt", "text/plain", text
# Paste depends only on the actual text
# and of course the function doPaste
paste = useCallback paste, [text, doPaste]
<div className="content-pastebin">
{renderDialog()}