Skip to content

Commit c577d75

Browse files
authored
fix: 🐛 fix problem ssr with persist Gate - Improve services int (#13)
* fix: 🐛 fix problem ssr with persist GAte - Improve services int * feat: 🎸 completelly remove redux-persist from project
1 parent cb2122a commit c577d75

File tree

21 files changed

+111
-325
lines changed

21 files changed

+111
-325
lines changed

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
. "$(dirname -- "$0")/_/husky.sh"
33

44
npx --no-install commitlint --edit $1
5+
npm run lint:fix
56
npx lint-staged

commitlint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
extends: ['@commitlint/config-conventional']
2+
extends: ['@commitlint/config-conventional'],
33
}

package-lock.json

Lines changed: 12 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"test": "jest --forceExit --coverage --no-cache --detectOpenHandles --passWithNoTests",
1010
"test:dev": "jest --watch --forceExit --coverage --no-cache --detectOpenHandles --passWithNoTests",
1111
"lint": "next lint",
12+
"lint:fix": "eslint --fix --ext .js,.jsx,.tsx,.ts .",
1213
"prepare": "husky install"
1314
},
1415
"dependencies": {
@@ -22,7 +23,6 @@
2223
"react-dom": "18.2.0",
2324
"react-icons": "^4.10.1",
2425
"react-redux": "^8.1.2",
25-
"redux-persist": "^6.0.0",
2626
"tailwind-variants": "^0.1.13",
2727
"tailwindcss": "3.3.3"
2828
},
@@ -35,7 +35,7 @@
3535
"@testing-library/jest-dom": "^5.17.0",
3636
"@testing-library/react": "^14.0.0",
3737
"@testing-library/user-event": "^14.4.3",
38-
"@types/node": "20.4.5",
38+
"@types/node": "20.4.6",
3939
"@types/react": "18.2.18",
4040
"@types/react-dom": "18.2.7",
4141
"@typescript-eslint/eslint-plugin": "^6.2.1",
@@ -44,15 +44,15 @@
4444
"commitlint": "^17.6.7",
4545
"eslint": "^8.46.0",
4646
"eslint-config-next": "13.4.12",
47-
"eslint-config-prettier": "^8.9.0",
47+
"eslint-config-prettier": "^8.10.0",
4848
"eslint-plugin-prettier": "^5.0.0",
4949
"eslint-plugin-simple-import-sort": "^10.0.0",
5050
"husky": "^8.0.3",
5151
"jest": "^29.6.2",
5252
"jest-environment-jsdom": "^29.6.2",
5353
"jest-fetch-mock": "^3.0.3",
5454
"lint-staged": "^13.2.3",
55-
"prettier": "^3.0.0",
55+
"prettier": "^3.0.1",
5656
"typescript": "5.1.6",
5757
"web-vitals": "^3.4.0",
5858
"webpack": "^5.88.2"

src/app/(redux)/redux-persist-example/page.test.tsx

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

src/app/(redux)/redux-persist-example/page.tsx

Lines changed: 0 additions & 41 deletions
This file was deleted.
Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,8 @@
1-
'use client'
2-
31
import { ReactElement } from 'react'
4-
import Image from 'next/image'
5-
6-
import { api } from '@/redux/api/api'
7-
import User from '@/types/user/user.type'
8-
9-
export default function Page(): ReactElement {
10-
const { isLoading, isFetching, data, error } = api.useGetUsersQuery(null)
112

12-
return (
13-
<main style={{ maxWidth: 1200, marginInline: 'auto', padding: 20 }}>
14-
{error && <p>Oh no, there was an error</p>}
3+
import ServiceExampleScreen from '@/screens/service-example-screen/service-example-screen'
4+
import fetchFromApi from '@/utils/fetchFromApi'
155

16-
{isLoading || (isFetching && <p>Loading...</p>)}
17-
{data && (
18-
<div
19-
style={{
20-
display: 'grid',
21-
gridTemplateColumns: '1fr 1fr 1fr 1fr',
22-
gap: 20,
23-
}}
24-
>
25-
{data.map((user: User) => (
26-
<div
27-
key={user.id}
28-
style={{ border: '1px solid #ccc', textAlign: 'center' }}
29-
>
30-
<Image
31-
src={`https://robohash.org/${user.id}?set=set2&size=180x180`}
32-
alt={user.name}
33-
height="180"
34-
width="180"
35-
style={{ margin: 'auto' }}
36-
/>
37-
<h3>{user.name}</h3>
38-
</div>
39-
))}
40-
</div>
41-
)}
42-
</main>
43-
)
6+
export default async function Page(): Promise<ReactElement> {
7+
return <ServiceExampleScreen ssdata={(await fetchFromApi('getUsers')).data} />
448
}

src/components/DarkModeButton/dark-mode-button.component.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const DarkModeButton = (): ReactElement | null => {
1818
return (
1919
<button
2020
className="absolute right-4 bottom-4"
21+
aria-label="Dark/Light Mode"
2122
onClick={() => (theme === 'dark' ? setTheme('light') : setTheme('dark'))}
2223
>
2324
{theme === 'dark' ? <FaMoon /> : <FaSun />}

src/providers/redux-provider/redux-provider.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,13 @@
22

33
import { ReactElement, ReactNode } from 'react'
44
import { Provider } from 'react-redux'
5-
import { PersistGate } from 'redux-persist/integration/react'
65

7-
import { persistor } from '@/redux/persistor/persistor'
86
import getStore from '@/redux/store/store'
97

108
export default function ReduxProvider({
119
children,
1210
}: {
1311
children: ReactNode
1412
}): ReactElement {
15-
return (
16-
<Provider store={getStore()}>
17-
<PersistGate loading={null} persistor={persistor}>
18-
{children}
19-
</PersistGate>
20-
</Provider>
21-
)
13+
return <Provider store={getStore()}>{children}</Provider>
2214
}

src/redux/createNoopStorage/createNoopStorage.test.tsx

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

0 commit comments

Comments
 (0)