Skip to content

Commit 9af0020

Browse files
committed
fix: clean up LangSelect
1 parent 5c5ae42 commit 9af0020

2 files changed

Lines changed: 6 additions & 49 deletions

File tree

app/component/LangSelect.js

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import PropTypes from 'prop-types';
21
import React from 'react';
3-
import { matchShape, routerShape } from 'found';
2+
import { matchShape } from 'found';
43
import { useIntl } from 'react-intl';
5-
import connectToStores from 'fluxible-addons-react/connectToStores';
64
import { configShape } from '../util/shapes';
5+
import { useConfigContext } from '../configurations/ConfigContext';
76

87
const language = (lang, highlight, match, intl) => {
98
const aria = highlight
@@ -25,36 +24,21 @@ const language = (lang, highlight, match, intl) => {
2524
);
2625
};
2726

28-
const LangSelect = ({ currentLanguage }, { config, match }) => {
27+
const LangSelect = ({}, { match }) => { // eslint-disable-line
28+
const config = useConfigContext();
2929
const intl = useIntl();
3030
return (
3131
<div key="lang-select" id="lang-select">
3232
{config.availableLanguages.map(lang =>
33-
language(lang, lang === currentLanguage, match, intl),
33+
language(lang, lang === config.language, match, intl),
3434
)}
3535
</div>
3636
);
3737
};
3838

39-
LangSelect.displayName = 'LangSelect';
40-
41-
LangSelect.propTypes = {
42-
currentLanguage: PropTypes.string.isRequired,
43-
};
44-
4539
LangSelect.contextTypes = {
46-
executeAction: PropTypes.func.isRequired,
4740
config: configShape.isRequired,
48-
router: routerShape.isRequired,
4941
match: matchShape.isRequired,
5042
};
5143

52-
const connected = connectToStores(
53-
LangSelect,
54-
['PreferencesStore'],
55-
context => ({
56-
currentLanguage: context.getStore('PreferencesStore').getLanguage(),
57-
}),
58-
);
59-
60-
export { connected as default, LangSelect as Component };
44+
export default LangSelect;

test/unit/component/LangSelect.test.js

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)