diff --git a/native/invite-links/manage-public-link-screen.react.js b/native/invite-links/manage-public-link-screen.react.js
--- a/native/invite-links/manage-public-link-screen.react.js
+++ b/native/invite-links/manage-public-link-screen.react.js
@@ -37,24 +37,39 @@
const [name, setName] = React.useState(
inviteLink?.name ?? Math.random().toString(36).slice(-9),
);
+ const [error, setError] = React.useState(null);
const dispatchActionPromise = useDispatchActionPromise();
const callCreateOrUpdatePublicLink = useServerCall(createOrUpdatePublicLink);
+ const createActionPromise = React.useCallback(async () => {
+ setError(null);
+ try {
+ return await callCreateOrUpdatePublicLink({
+ name,
+ communityID: community.id,
+ });
+ } catch (e) {
+ setError(e.message);
+ throw e;
+ }
+ }, [callCreateOrUpdatePublicLink, community.id, name]);
const createInviteLink = React.useCallback(() => {
dispatchActionPromise(
createOrUpdatePublicLinkActionTypes,
- callCreateOrUpdatePublicLink({
- name,
- communityID: community.id,
- }),
+ createActionPromise(),
);
- }, [callCreateOrUpdatePublicLink, community.id, dispatchActionPromise, name]);
+ }, [createActionPromise, dispatchActionPromise]);
const createOrUpdatePublicLinkStatus = useSelector(
createOrUpdatePublicLinkStatusSelector,
);
const styles = useStyles(unboundStyles);
+ let errorComponent = null;
+ if (error) {
+ errorComponent = {error};
+ }
+
return (
@@ -80,6 +95,7 @@
editable={createOrUpdatePublicLinkStatus !== 'loading'}
/>
+ {errorComponent}