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> {
81
81
openShareDialogOnClick ?: boolean ;
82
82
opts : LinkOptions ;
83
83
/**
84
- * URL of the shared page
84
+ * URL of the shared page, can be an async function that resolves a URL
85
85
*/
86
- url : string ;
86
+ url : string | ( ( ) => Promise < string > ) ;
87
87
style ?: React . CSSProperties ;
88
88
windowWidth ?: number ;
89
89
windowHeight ?: number ;
@@ -93,6 +93,7 @@ interface CustomProps<LinkOptions> {
93
93
* `onClick`. If you do not return promise, `onClick` is called immediately.
94
94
*/
95
95
beforeOnClick ?: ( ) => Promise < void > | void ;
96
+
96
97
/**
97
98
* Takes a function to be called after closing share dialog.
98
99
*/
@@ -138,11 +139,16 @@ export default class ShareButton<LinkOptions> extends Component<Props<LinkOption
138
139
disabled,
139
140
networkLink,
140
141
onClick,
141
- url,
142
142
openShareDialogOnClick,
143
143
opts,
144
144
} = this . props ;
145
145
146
+ let url = this . props . url ;
147
+
148
+ if ( typeof url == 'function' ) {
149
+ url = await url ( ) ;
150
+ }
151
+
146
152
const link = networkLink ( url , opts ) ;
147
153
148
154
if ( disabled ) {
You can’t perform that action at this time.
0 commit comments