Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yauheni/79513/no language redirection from derivapp #6824

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/components/src/components/static-url/static-url.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React from 'react';
import { getStaticUrl, PlatformContext } from '@deriv/shared';
import { getStaticUrl, PlatformContext, setUrlLanguage } from '@deriv/shared';
import { getLanguage } from '@deriv/translations';

const StaticUrl = ({ href, is_document, children, ...props }) => {
const { is_appstore } = React.useContext(PlatformContext);
setUrlLanguage(getLanguage());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to call this func synchronously, as getStaticUrl func uses language variable in the same scope

Copy link
Contributor

@maryia-deriv maryia-deriv Oct 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
setUrlLanguage(getLanguage());
const getHref = () => {
setUrlLanguage(getLanguage());
return getStaticUrl(href, { is_appstore }, is_document);
}

this way we'll set a correct language right at the moment when link href is set 😊 please check if it works)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this is one of my variants for implementation :) . But on the whole it is the same synchronous code, which is executed with rendering.
So there are no differences :)
But I like this as it looks like more clear. will implement 👍


return (
<a href={getStaticUrl(href, { is_appstore }, is_document)} rel='noopener noreferrer' target='_blank' {...props}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<a href={getHref()} rel='noopener noreferrer' target='_blank' {...props}>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The anchor tag is what the StaticUrl component renders. So does it make a diff between your suggestion and @yauheni-kryzhyk-deriv's implementation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, there is no differences, just a little bit different approach.

Expand Down