Skip to content
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

fix: pass previewUrlCallback function to the global scope #270

Merged
merged 2 commits into from
Jul 23, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const useWidget = (
locale,
localeTranslations,
localePluralize,
previewUrlCallback,
...options
},
uploadcare
Expand All @@ -67,6 +68,9 @@ const useWidget = (
if (localeTranslations) {
window.UPLOADCARE_LOCALE_TRANSLATIONS = localeTranslations
}
if (previewUrlCallback) {
window.UPLOADCARE_PREVIEW_URL_CALLBACK = previewUrlCallback
}

uploadcare.plugin((internal) => {
internal.locale.rebuild({
Expand All @@ -80,6 +84,7 @@ const useWidget = (
if (locale) delete window.UPLOADCARE_LOCALE
if (localePluralize) delete window.UPLOADCARE_LOCALE_PLURALIZE
if (localeTranslations) delete window.UPLOADCARE_LOCALE_TRANSLATIONS
if (previewUrlCallback) delete window.UPLOADCARE_PREVIEW_URL_CALLBACK
}
}, [locale, localeTranslations, localePluralize])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use hook useCallback for set function in deps.
previewUrlCallback

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😨 fixed


Expand Down