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!

fix: bug

kruzhambusf7b8701895e5
diff --git a/package.json b/package.json
index a6f072cc3..b159e51a7 100644
--- a/package.json
+++ b/package.json
@@ -65,6 +65,9 @@
"eslint:recommended",
"plugin:react/recommended"
],
+ "globals": {
+ "JSX": "readonly"
+ },
"plugins": [
"lodash",
"react-hooks"
diff --git a/src/App.jsx b/src/App.tsx
similarity index 89%
rename from src/App.jsx
rename to src/App.tsx
index 10acbe56d..52a7b5ee1 100644
--- a/src/App.jsx
+++ b/src/App.tsx
@@ -2,7 +2,8 @@ import React, {
useEffect, lazy, Suspense, useState,
} from 'react'
import { Switch, Route, useLocation } from 'react-router-dom'
-import { useDispatch, useSelector } from 'react-redux'
+import { useSelector } from 'react-redux'
+// @ts-ignore
import { useAlert } from '@blaumaus/react-alert'
// import Snowfall from 'react-snowfall'
import cx from 'clsx'
@@ -24,7 +25,9 @@ import { getAccessToken } from 'utils/accessToken'
import { authActions } from 'redux/reducers/auth'
import { errorsActions } from 'redux/reducers/errors'
import { alertsActions } from 'redux/reducers/alerts'
+import { StateType, useAppDispatch } from 'redux/store'
import UIActions from 'redux/reducers/ui'
+
import routes from 'routes'
import { getRefreshToken } from 'utils/refreshToken'
import { authMe } from './api'
@@ -59,7 +62,11 @@ const minimalFooterPages = [
'/projects', '/dashboard', '/settings', '/contact',
]
-const Fallback = ({ isMinimalFooter }) => {
+type FallbackProps = {
+ isMinimalFooter: boolean
+}
+
+const Fallback = ({ isMinimalFooter }: FallbackProps): JSX.Element => {
const [showLoader, setShowLoader] = useState(false)
useEffect(() => {
@@ -86,21 +93,21 @@ const Fallback = ({ isMinimalFooter }) => {
}
const App = () => {
- const dispatch = useDispatch()
+ const dispatch = useAppDispatch()
const location = useLocation()
const alert = useAlert()
const {
loading, authenticated, user,
- } = useSelector(state => state.auth)
- const { theme } = useSelector(state => state.ui.theme)
- const { error } = useSelector(state => state.errors)
- const { message, type } = useSelector(state => state.alerts)
+ } = useSelector((state: StateType) => state.auth)
+ const { theme } = useSelector((state: StateType) => state.ui.theme)
+ const { error } = useSelector((state: StateType) => state.errors)
+ const { message, type } = useSelector((state: StateType) => state.alerts)
// const themeType = useSelector(state => state.ui.theme.type)
const accessToken = getAccessToken()
const refreshToken = getRefreshToken()
useEffect(() => {
- const eventCallback = (data) => {
+ const eventCallback = (data: any) => {
dispatch(UIActions.setPaddleLastEvent(data))
}
// eslint-disable-next-line no-use-before-define
@@ -109,8 +116,8 @@ const App = () => {
function paddleSetup() {
if (isSelfhosted) {
clearInterval(interval)
- } else if (window.Paddle) {
- window.Paddle.Setup({
+ } else if ((window as any)?.Paddle) {
+ (window as any).Paddle.Setup({
vendor: 139393,
eventCallback,
})
@@ -136,7 +143,7 @@ const App = () => {
try {
const me = await authMe()
// dispatch(UIActions.setThemeType(me.theme))
- dispatch(authActions.loginSuccess(me))
+ dispatch(authActions.loginSuccessful(me))
dispatch(authActions.finishLoading())
} catch (e) {
dispatch(authActions.logout())
@@ -169,7 +176,8 @@ const App = () => {
const isMinimalFooter = _some(minimalFooterPages, (page) => _includes(location.pathname, page))
return (
- (!accessToken || !loading) && (
+ <>
+ {(!accessToken || !loading) && (
// eslint-disable-next-line react/jsx-no-useless-fragment
<Suspense fallback={<></>}>
<Header
@@ -184,9 +192,10 @@ const App = () => {
{/* {location.pathname !== routes.main && themeType === THEME_TYPE.christmas && (
<Snowfall snowflakeCount={10} />
)} */}
+ {/* @ts-ignore */}
<ScrollToTop>
<Selfhosted>
- <Suspense fallback={<Fallback theme={theme} isMinimalFooter={isMinimalFooter} />}>
+ <Suspense fallback={<Fallback isMinimalFooter={isMinimalFooter} />}>
<Switch>
<Route path={routes.main} component={MainPage} exact />
<Route path={routes.signin} component={SignIn} exact />
@@ -223,7 +232,9 @@ const App = () => {
</ScrollToTop>
<Footer minimal={isMinimalFooter} authenticated={authenticated} />
</Suspense>
- )
+ )}
+ <div className='hidden' />
+ </>
)
}
diff --git a/src/index.tsx b/src/index.tsx
index f36c60136..063eb8ccc 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -60,7 +60,6 @@ root.render(
<HelmetProvider>
<BrowserRouter>
<I18nextProvider i18n={i18next}>
- {/* @ts-ignore */}
<App />
</I18nextProvider>
</BrowserRouter>
diff --git a/src/redux/store/index.ts b/src/redux/store/index.ts
index 2344ea1f4..f48661bac 100644
--- a/src/redux/store/index.ts
+++ b/src/redux/store/index.ts
@@ -1,5 +1,6 @@
import { combineReducers, configureStore } from '@reduxjs/toolkit'
import createSagaMiddleware from 'redux-saga'
+import { useDispatch } from 'react-redux'
import rootSaga from '../sagas'
import authSlice from '../reducers/auth'
import errorsSlice from '../reducers/errors'
@@ -34,5 +35,6 @@ export const store = configureStore({
sagaMiddleware.run(rootSaga)
export type RootState = ReturnType<typeof rootReducer>
-export type AppStore = ReturnType<typeof store.getState>
export type AppDispatch = typeof store.dispatch
+export const useAppDispatch: () => AppDispatch = useDispatch
+export type StateType = ReturnType<typeof store.getState>