Skip to content

Commit 6c63faa

Browse files
Update packages (react18, next12, typescript, styled-component)
1 parent 72a98d2 commit 6c63faa

File tree

11 files changed

+221
-1595
lines changed

11 files changed

+221
-1595
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/.idea/
22
/node_modules/
33
/.next/
4+
tsconfig.tsbuildinfo

next-env.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
/// <reference types="next" />
2-
/// <reference types="next/types/global" />
32
/// <reference types="next/image-types/global" />
3+
4+
// NOTE: This file should not be edited
5+
// see https://nextjs.org/docs/basic-features/typescript for more information.

package.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,26 @@
2626
"js-cookie": "^3.0.1",
2727
"lodash": "^4.17.21",
2828
"moment": "^2.29.1",
29-
"next": "^11.0.1",
29+
"next": "12.3.1",
3030
"nookies": "^2.5.2",
31-
"react": "^17.0.2",
32-
"react-dom": "^17.0.2",
31+
"react": "^18.2.0",
32+
"react-dom": "^18.2.0",
3333
"react-hook-form": "^7.38.0",
3434
"react-redux": "^8.0.2",
3535
"react-toastify": "^7.0.4",
3636
"redux-saga": "^1.1.3",
3737
"reselect": "^4.0.0",
3838
"sha512-es": "^1.8.2",
39-
"styled-components": "^5.3.0",
39+
"styled-components": "5.3.6",
4040
"styled-reset": "^4.3.4",
4141
"video.js": "^7.14.3"
4242
},
4343
"devDependencies": {
4444
"@types/js-cookie": "^3.0.2",
4545
"@types/lodash": "^4.14.172",
46-
"@types/moment": "^2.13.0",
47-
"@types/next": "^9.0.0",
48-
"@types/react": "^17.0.16",
49-
"@types/react-dom": "^17.0.9",
46+
"@types/node": "18.7.23",
47+
"@types/react": "18.0.21",
48+
"@types/react-dom": "18.0.6",
5049
"@types/react-toastify": "^4.1.0",
5150
"@types/redux-saga": "^0.10.5",
5251
"@types/styled-components": "^5.1.12",
@@ -56,6 +55,6 @@
5655
"eslint": "^7.32.0",
5756
"eslint-config-next": "^11.0.1",
5857
"ts-node": "^10.2.0",
59-
"typescript": "^4.7.4"
58+
"typescript": "4.8.3"
6059
}
6160
}

pages/_app.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ import {thunkRefreshSetUser} from '@store/reducers/user';
1616
import {QueryClient, QueryClientProvider} from '@tanstack/react-query';
1717

1818
export default function MyApp(props: AppProps) {
19-
if (props.pageProps.notifyRedirect) {
20-
return <NotifyRedirect notifyRedirect={props.pageProps.notifyRedirect as NotifyRedirectProps['notifyRedirect']}/>;
19+
if ('notifyRedirect' in props.pageProps) {
20+
const {notifyRedirect} = props.pageProps as NotifyRedirectProps;
21+
return <NotifyRedirect notifyRedirect={notifyRedirect}/>;
2122
}
2223

2324
return (
@@ -55,18 +56,22 @@ function InnerApp({Component, pageProps}: AppProps) {
5556

5657
const Layout = 'layout' in Component ? (Component as any).layout : null;
5758

59+
//https://github.com/styled-components/styled-components/issues/3738
60+
const ThemeProviderProxy: any = ThemeProvider;
61+
const GlobalStyleProxy: any = GlobalStyle;
62+
5863
return (
5964
<QueryClientProvider client={queryClient}>
60-
<ThemeProvider theme={theme}>
61-
<GlobalStyle/>
65+
<ThemeProviderProxy theme={theme}>
66+
<GlobalStyleProxy/>
6267
{Layout === null ? (
6368
<Component {...pageProps}/>
6469
) : (
6570
<Layout>
6671
<Component {...pageProps}/>
6772
</Layout>
6873
)}
69-
</ThemeProvider>
74+
</ThemeProviderProxy>
7075
</QueryClientProvider>
7176
);
7277
}

pages/api/age.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type {NextApiRequest, NextApiResponse} from 'next';
22

33
export default function age(request: NextApiRequest, response: NextApiResponse) {
44
try {
5-
const age = request.query.name.length;
5+
const age = request.query?.name?.length as number;
66
response.json({age});
77
} catch (error) {
88
response.json({age: 0});

pages/examples/api/react-query/mutation-reset-error.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ export default function Page() {
3737
return (
3838
<StyledForm onSubmit={onSubmit}>
3939
<InputText value={title} onChangeText={onChangeTitle} placeholder="대충 수정하기전 제목"/>
40-
{/* 이렇게 매번 assertion 하는게 최선인가? */}
41-
{error && <ErrorMessage>{(error as Error).message}</ErrorMessage>}
40+
{!error ? null : <ErrorMessage>{(error as Error).message}</ErrorMessage>}
4241
<Button type="submit">수정</Button>
4342
</StyledForm>
4443
);

src/util/custom-hooks/useCheckableList.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export interface UseCheckableListResult<T extends Object> {
2020
}
2121

2222
// 별도의 체크 목록 state를 위한 custom hooks
23-
export default function useCheckableList<T>({pkExtractor, list}: UseCheckableListParam<T>): UseCheckableListResult<T> {
23+
export default function useCheckableList<T extends Object>({pkExtractor, list}: UseCheckableListParam<T>): UseCheckableListResult<T> {
2424
const [checkedList, setCheckedList] = useState(list.map(item => ({
2525
pk: pkExtractor(item),
2626
checked: false
@@ -116,7 +116,7 @@ export default function useCheckableList<T>({pkExtractor, list}: UseCheckableLis
116116
};
117117
}
118118

119-
function useAnotherWay<T>({pkExtractor, list}: UseCheckableListParam<T>): UseCheckableListResult<T> {
119+
function useAnotherWay<T extends Object>({pkExtractor, list}: UseCheckableListParam<T>): UseCheckableListResult<T> {
120120
const [selectedList, setSelectedList] = useState<PkType[]>([]);
121121

122122
useEffectFromTheSecondTime(useCallback(() => {

src/util/extend/object.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export function reverse<K extends string, V extends string>(target: Record<K, V>
22
const targetKeys = Object.keys(target) as K[];
33
return targetKeys.reduce((a, key) => {
44
const value = target[key];
5+
// eslint-disable-next-line no-param-reassign
56
a[value] = key;
67
return a;
78
}, {} as Record<V, K>);

src/util/extend/state.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* const [state, setState] = useState({key1: 'value1', key2: 'value2', ...rest});
44
* setState(prevState => keepRestPrevState(prevState, ['key1'], {key1: 'changed-value1'}));
55
*/
6-
export default function keepRestPrevState<V>(prevState: V, changeKeys: (keyof V)[], value: Partial<V>): V {
6+
export default function keepRestPrevState<V extends Object>(prevState: V, changeKeys: (keyof V)[], value: Partial<V>): V {
77
return Object.keys(prevState).reduce((a, b) => {
88
if (changeKeys.includes(b as keyof V)) {
99
// @ts-ignore

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
"src/util/*"
4040
]
4141
},
42-
"importsNotUsedAsValues": "error"
42+
"importsNotUsedAsValues": "error",
43+
"incremental": false
4344
},
4445
"include": [
4546
"next-env.d.ts",

0 commit comments

Comments
 (0)