-
Notifications
You must be signed in to change notification settings - Fork 140
AB#174 General Traffic now improvements #5608
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
base: next
Are you sure you want to change the base?
Conversation
| const lang = document.cookie | ||
| .split(';') | ||
| .find(item => item.indexOf('lang=') > -1) | ||
| .split('=')[1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a better way to get a hold of the current language?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use app/store/PreferencesStore, where the current language is stored:
function component (props, context) {
const lang = context.getStore('PreferencesStore').getLanguage();
}
Actually the current way presented above is some sort of mistake. Stores are used for emitting changes which trigger component rendering. Lang does not change dynamically. UI server sends a cookie at first page load. If user changes the language, new page loading takes place. We could simply store the language to configuration.
| /* MAJOR_CHANGES: { | ||
| fi: 'TODO', | ||
| sv: 'TODO', | ||
| en: 'TODO', | ||
| }, */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is currently unclear where this "suuret muutokset" link that was requested to be implemented should take the user
| export const useTranslationsContext = () => { | ||
| const intl = useContext(IntlContext); | ||
| if (!intl) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure why you add new context providers? The old way of accesing config or intl from standard context looks so simple:
function mycomponent(props, context) {
const intl = context.intl;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old way of accessing context is deprecated in React versions newer than 16, so I think this is a welcoming change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Futureproofing as @hjvuor said.
Accessing the context via a provider is also simpler in deeply nested components as there's no need to drill down the context prop.
Proposed Changes
Pull Request Check List
Review