0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-27 21:39:16 -05:00

fix(ui): fix create account page reload issue (#832)

fix create account page reload issue
This commit is contained in:
simeng-li 2022-05-16 13:47:09 +08:00 committed by GitHub
parent 78d3bb6045
commit e2217584a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View file

@ -1,6 +1,7 @@
import classNames from 'classnames';
import React, { ReactNode, AnchorHTMLAttributes } from 'react';
import { TFuncKey, useTranslation } from 'react-i18next';
import { Link } from 'react-router-dom';
import * as styles from './index.module.scss';
@ -9,11 +10,20 @@ export type Props = AnchorHTMLAttributes<HTMLAnchorElement> & {
children?: ReactNode;
text?: TFuncKey<'translation', 'main_flow'>;
type?: 'primary' | 'secondary';
to?: string;
};
const TextLink = ({ className, children, text, type = 'primary', ...rest }: Props) => {
const TextLink = ({ className, children, text, type = 'primary', to, ...rest }: Props) => {
const { t } = useTranslation(undefined, { keyPrefix: 'main_flow' });
if (to) {
return (
<Link className={classNames(styles.link, styles[type], className)} to={to}>
{children ?? (text ? t(text) : '')}
</Link>
);
}
return (
<a className={classNames(styles.link, styles[type], className)} {...rest} rel="noreferrer">
{children ?? (text ? t(text) : '')}

View file

@ -87,7 +87,7 @@ export const CreateAccountLink = ({
<TextLink
className={styles.createAccount}
type="secondary"
href={`/register/${primarySignInMethod}`}
to={`/register/${primarySignInMethod}`}
text="action.create_account"
/>
</>