import axios from 'axios';
import React, { useEffect, useState } from 'react';
+import { withTranslation } from 'react-i18next';
import { useParams } from 'react-router-dom';
import ErrorBoundary from '../common/ErrorBoundary';
import Loading from '../common/Loading';
import NotFound from '../pages/NotFound';
import Detail from '../techniques/Detail';
+import { getTranslation } from '../../helpers/Technique';
+import i18n from '../../i18n';
const Technique = () => {
const params = useParams();
setError(null);
setLoading(false);
setTechnique(response.data);
- window.document.title = response.data.title;
})
.catch(error => {
setError(error);
};
}, [name]);
+ useEffect(() => {
+ if (technique) {
+ window.document.title = getTranslation(technique, 'title', i18n.language);
+ }
+ }, [technique, i18n.language]);
+
if (loading) {
return <Loading />;
}
</ErrorBoundary>;
};
-export default Technique;
+export default withTranslation()(Technique);