Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

redux to remix

Maksim Mrugb3fd85d9572d
diff --git a/app/entry.client.tsx b/app/entry.client.tsx
index 1a89b318b..6d0420d40 100644
--- a/app/entry.client.tsx
+++ b/app/entry.client.tsx
@@ -15,11 +15,9 @@ import Backend from 'i18next-http-backend'
import { getInitialNamespaces } from 'remix-i18next'
import _isString from 'lodash/isString'
import _includes from 'lodash/includes'
-import { store } from 'redux/store'
-import { Provider } from 'react-redux'
+import { whitelist, defaultLanguage } from 'redux/constants'
import i18n from './i18n'
-import { whitelist, defaultLanguage } from './constants'
import { setItem, getItem } from './utils/localstorage'
async function hydrate() {
@@ -91,9 +89,7 @@ async function hydrate() {
document,
<I18nextProvider i18n={i18next}>
<StrictMode>
- <Provider store={store}>
- <RemixBrowser />
- </Provider>
+ <RemixBrowser />
</StrictMode>
</I18nextProvider>,
)
diff --git a/app/redux/reducers/ui/theme.ts b/app/redux/reducers/ui/theme.ts
index b3d786dea..4791a4237 100644
--- a/app/redux/reducers/ui/theme.ts
+++ b/app/redux/reducers/ui/theme.ts
@@ -3,26 +3,26 @@ import _includes from 'lodash/includes'
import { LS_THEME_SETTING, SUPPORTED_THEMES, THEME_TYPE } from 'redux/constants'
const setThemeToDOM = (theme: string) => {
- const root = window.document.documentElement
+ // const root = window.document.documentElement
const isDark = theme === 'dark'
- root.classList.remove(isDark ? 'light' : 'dark')
- root.classList.add(theme)
+ // root.classList.remove(isDark ? 'light' : 'dark')
+ // root.classList.add(theme)
}
const setTheme = (theme: string): string => {
setThemeToDOM(theme)
- localStorage.setItem(LS_THEME_SETTING, theme)
+ // localStorage.setItem(LS_THEME_SETTING, theme)
return theme
}
const getInitialTheme = (): 'light' | 'dark' => {
if (typeof window !== 'undefined' && window.localStorage) {
- const lsTheme: any = window.localStorage.getItem(LS_THEME_SETTING)
- if (_includes(SUPPORTED_THEMES, lsTheme)) {
- setThemeToDOM(lsTheme)
- return lsTheme
- }
+ // const lsTheme: any = window.localStorage.getItem(LS_THEME_SETTING)
+ // if (_includes(SUPPORTED_THEMES, lsTheme)) {
+ // setThemeToDOM(lsTheme)
+ // return lsTheme
+ // }
const userMedia = window.matchMedia('(prefers-color-scheme: dark)')
if (userMedia.matches) {
diff --git a/app/root.tsx b/app/root.tsx
index 77d008586..b87a34415 100644
--- a/app/root.tsx
+++ b/app/root.tsx
@@ -7,6 +7,8 @@ import {
Scripts,
ScrollRestoration,
} from '@remix-run/react'
+import { store } from 'redux/store'
+import { Provider } from 'react-redux'
import Footer from './components/Footer'
import Header from './components/Header'
@@ -27,12 +29,14 @@ export default function App() {
<Links />
</head>
<body>
- <Header />
- <Outlet />
- <ScrollRestoration />
- <Scripts />
- {process.env.NODE_ENV === 'development' && <LiveReload />}
- <Footer />
+ <Provider store={store}>
+ <Header />
+ <Outlet />
+ <ScrollRestoration />
+ <Scripts />
+ {process.env.NODE_ENV === 'development' && <LiveReload />}
+ <Footer />
+ </Provider>
</body>
</html>
)
diff --git a/app/utils/localstorage.ts b/app/utils/localstorage.ts
index 296c2cd5f..0604492bb 100644
--- a/app/utils/localstorage.ts
+++ b/app/utils/localstorage.ts
@@ -12,28 +12,28 @@ type setItemType = (key: string, value: string) => void
export const setItem: setItemType = (key, value) => {
currentLocalStorage[key] = value
- localStorage.setItem(key, value)
+ // localStorage.setItem(key, value)
}
type getItemType = (key: string) => any
export const getItem: getItemType = (key) => {
- if (currentLocalStorage[key]) {
- return currentLocalStorage[key]
- }
+ // if (currentLocalStorage[key]) {
+ // return currentLocalStorage[key]
+ // }
- const storedValue: any = localStorage.getItem(key)
+ // const storedValue: any = localStorage.getItem(key)
- try {
- return JSON.parse(storedValue)
- } catch {
- return storedValue
- }
+ // try {
+ // return JSON.parse(storedValue)
+ // } catch {
+ // return storedValue
+ // }
}
type removeItemType = (key: string) => void
export const removeItem: removeItemType = (key) => {
- delete currentLocalStorage[key]
- localStorage.removeItem(key)
+ // delete currentLocalStorage[key]
+ // localStorage.removeItem(key)
}