From 9f7b4b795d1f6323a17323ac12d2e1b4e5335306 Mon Sep 17 00:00:00 2001 From: thomasrosen Date: Thu, 29 Apr 2021 09:58:40 +0200 Subject: [PATCH] moved AppLanguageWrapper to index.js --- src/App.js | 40 ++-------------------------------------- src/index.js | 38 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 40 deletions(-) diff --git a/src/App.js b/src/App.js index 1652824..0954822 100644 --- a/src/App.js +++ b/src/App.js @@ -1,4 +1,4 @@ -import { useState, useEffect, useCallback } from 'react' +import { useState, useCallback } from 'react' import './App.css' import { useDropzone } from 'react-dropzone' import mergeImages from 'merge-images' @@ -9,11 +9,8 @@ import VoltLogoPurple from './VoltLogoPurple.svg' import purpleBG from './purpleBG.png' import empty_1x1 from './empty_1x1.png' -import 'intl-pluralrules' -import { AppLocalizationProvider, locales } from './l10n.js' import { withLocalization, Localized } from './Localized.js' - const frameSize = 1080 function getOrientation(file, callback) { @@ -405,37 +402,4 @@ function App({ getString, locales, currentLocale, onLanguageChange }) { ) } -const AppLocalized = withLocalization(App) - - -function AppLanguageWrapper() { - const [userLocales, setUserLocales] = useState(navigator.languages) - const [currentLocale, setCurrentLocale] = useState(null) - - useEffect(() => { - let systemLocales = navigator.languages - if (!!systemLocales || Array.isArray(systemLocales)) { - for (const locale of systemLocales) { - window.umami.trackEvent('L: ' + locale) // Log Locale / Languages - } - } - }, []) - - const handleLanguageChange = useCallback(event => { - setUserLocales([event.target.dataset.locale]) - }, [setUserLocales]) - - const handleCurrentLocalesChange = useCallback(currentLocales => { - setCurrentLocale(currentLocales.length > 0 ? currentLocales[0] : '') - }, [setCurrentLocale]) - - return - - -} -export default withLocalization(AppLanguageWrapper) - +export default withLocalization(App) diff --git a/src/index.js b/src/index.js index 12e0a2a..fa4c933 100644 --- a/src/index.js +++ b/src/index.js @@ -1,11 +1,45 @@ -import React from 'react' +import React, { useState, useEffect, useCallback } from 'react' import ReactDOM from 'react-dom' import App from './App' import reportWebVitals from './reportWebVitals' +import 'intl-pluralrules' +import { AppLocalizationProvider, locales } from './l10n.js' + +function AppLanguageWrapper() { + const [userLocales, setUserLocales] = useState(navigator.languages) + const [currentLocale, setCurrentLocale] = useState(null) + + useEffect(() => { + let systemLocales = navigator.languages + if (!!systemLocales || Array.isArray(systemLocales)) { + for (const locale of systemLocales) { + window.umami.trackEvent('L: ' + locale) // Log Locale / Languages + } + } + }, []) + + const handleLanguageChange = useCallback(event => { + setUserLocales([event.target.dataset.locale]) + }, [setUserLocales]) + + const handleCurrentLocalesChange = useCallback(currentLocales => { + setCurrentLocale(currentLocales.length > 0 ? currentLocales[0] : '') + }, [setCurrentLocale]) + + return + + +} + + ReactDOM.render( - + , document.getElementById('root') )