diff --git a/app/stacks/InsideStack.tsx b/app/stacks/InsideStack.tsx
index f2f8c8d4f..6b903e9c9 100644
--- a/app/stacks/InsideStack.tsx
+++ b/app/stacks/InsideStack.tsx
@@ -101,7 +101,7 @@ const ChatsStackNavigator = () => {
options={SearchMessagesView.navigationOptions}
/>
-
+
{
options={SearchMessagesView.navigationOptions}
/>
-
+
{
- timeDateFormat: string;
- invite: TInvite;
-}
-class InviteUsersView extends React.Component {
- static navigationOptions = (): StackNavigationOptions => ({
- title: I18n.t('Invite_users')
- });
+type IInviteUsersViewProps = IBaseScreen;
- private rid: string;
+const InviteUsersView = ({ route, navigation }: IInviteUsersViewProps): React.ReactElement => {
+ const rid = route.params?.rid;
+ const timeDateFormat = useSelector((state: IApplicationState) => state.settings.Message_TimeAndDateFormat as string);
+ const invite = useSelector((state: IApplicationState) => state.inviteLinks.invite);
+ const { colors, theme } = useTheme();
+ const dispatch = useDispatch();
- constructor(props: IInviteUsersViewProps) {
- super(props);
- this.rid = props.route.params?.rid;
- }
+ useEffect(() => {
+ navigation.setOptions({
+ title: I18n.t('Invite_users')
+ });
+ }, []);
- componentDidMount() {
- const { dispatch } = this.props;
- dispatch(inviteLinksCreate(this.rid));
- }
+ useEffect(() => {
+ dispatch(inviteLinksCreate(rid));
+ return () => {
+ dispatch(inviteLinksClear());
+ };
+ }, []);
- componentWillUnmount() {
- const { dispatch } = this.props;
- dispatch(inviteLinksClear());
- }
-
- share = () => {
+ const share = () => {
logEvent(events.IU_SHARE);
- const { invite } = this.props;
if (!invite || !invite.url) {
return;
}
Share.share({ message: invite.url });
};
- edit = () => {
+ const edit = () => {
logEvent(events.IU_GO_IU_EDIT);
- const { navigation } = this.props;
- navigation.navigate('InviteUsersEditView', { rid: this.rid });
+ navigation.navigate('InviteUsersEditView', { rid });
};
- linkExpirationText = () => {
- const { timeDateFormat, invite } = this.props;
-
+ const linkExpirationText = () => {
if (!invite || !invite.url) {
return null;
}
@@ -90,38 +79,28 @@ class InviteUsersView extends React.Component {
return I18n.t('Your_invite_link_will_never_expire');
};
- renderExpiration = () => {
- const { theme } = this.props;
- const expirationMessage = this.linkExpirationText();
+ const renderExpiration = () => {
+ const expirationMessage = linkExpirationText();
return ;
};
- render() {
- const { theme, invite } = this.props;
- return (
-
- {/* @ts-ignore*/}
-
-
-
-
- {this.renderExpiration()}
-
-
-
-
-
-
- );
- }
-}
+ return (
+
+
+
+
+
+ {renderExpiration()}
+
+
+
+
+
+
+ );
+};
-const mapStateToProps = (state: IApplicationState) => ({
- timeDateFormat: state.settings.Message_TimeAndDateFormat as string,
- invite: state.inviteLinks.invite
-});
-
-export default connect(mapStateToProps)(withTheme(InviteUsersView));
+export default InviteUsersView;