File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -81,9 +81,9 @@ interface CustomProps<LinkOptions> {
8181 openShareDialogOnClick ?: boolean ;
8282 opts : LinkOptions ;
8383 /**
84- * URL of the shared page
84+ * URL of the shared page, can be an async function that resolves a URL
8585 */
86- url : string ;
86+ url : string | ( ( ) => Promise < string > ) ;
8787 style ?: React . CSSProperties ;
8888 windowWidth ?: number ;
8989 windowHeight ?: number ;
@@ -93,6 +93,7 @@ interface CustomProps<LinkOptions> {
9393 * `onClick`. If you do not return promise, `onClick` is called immediately.
9494 */
9595 beforeOnClick ?: ( ) => Promise < void > | void ;
96+
9697 /**
9798 * Takes a function to be called after closing share dialog.
9899 */
@@ -138,11 +139,16 @@ export default class ShareButton<LinkOptions> extends Component<Props<LinkOption
138139 disabled,
139140 networkLink,
140141 onClick,
141- url,
142142 openShareDialogOnClick,
143143 opts,
144144 } = this . props ;
145145
146+ let url = this . props . url ;
147+
148+ if ( typeof url == 'function' ) {
149+ url = await url ( ) ;
150+ }
151+
146152 const link = networkLink ( url , opts ) ;
147153
148154 if ( disabled ) {
You can’t perform that action at this time.
0 commit comments