inflearn logo
강의

Course

Instructor

Slack Clone Coding [Real-time Chat with React]

Q&A(Reason for not using CRA)

loadable import error

399

ryosuke kureha

13 asked

0

import { Switch, Route, Redirect } from 'react-router-dom'
// import Login from '@pages/Login'
// import SignUp from '@pages/SignUp'
const Login = loadable(() => import('@pages/Login')) // next dynamic import ?
const SignUp = loadable(() => import('@pages/SignUp'))
No overload matches this call.
Overload 1 of 3, '(loadFn: (props: unknown) => Promise<DefaultComponent<unknown>>, options?: OptionsWithoutResolver<unknown> | undefined): LoadableComponent<unknown>', gave the following error.
Type 'Promise<typeof import("/Users/ohyunseok/Documents/PROJECT/Slacku/react-frontend/pages/Login/index")>' is not assignable to type 'Promise<DefaultComponent<unknown>>'.
Type 'typeof import("/Users/ohyunseok/Documents/PROJECT/Slacku/react-frontend/pages/Login/index")' is not assignable to type 'DefaultComponent<unknown>'.
Property 'default' is missing in type 'typeof import("/Users/ohyunseok/Documents/PROJECT/Slacku/react-frontend/pages/Login/index")' but required in type 'DefaultImportedComponent<unknown>'.
Overload 2 of 3, '(loadFn: (props: any) => Promise<ComponentClass<any, any> | { default: ComponentClass<any, any>; }>, options?: Options<any, ComponentClass<any, any>> | undefined): LoadableClassComponent<...>', gave the following error.
Type 'Promise<typeof import("/Users/ohyunseok/Documents/PROJECT/Slacku/react-frontend/pages/Login/index")>' is not assignable to type 'Promise<ComponentClass<any, any> | { default: ComponentClass<any, any>; }>'.
Type 'typeof import("/Users/ohyunseok/Documents/PROJECT/Slacku/react-frontend/pages/Login/index")' is not assignable to type 'ComponentClass<any, any> | { default: ComponentClass<any, any>; }'.
Property 'default' is missing in type 'typeof import("/Users/ohyunseok/Documents/PROJECT/Slacku/react-frontend/pages/Login/index")' but required in type '{ default: ComponentClass<any, any>; }'.
ts(2769)
index.d.ts(11, 5): 'default' is declared here.
index.d.ts(85, 13): The expected type comes from the return type of this signature.
import error가 나는 이유가 뭔가요? 제로초님?
에러를 찾아냈습니다.
변경전
import React from 'react'

export const Login = () => {
return <div>
로그인
</div>
}
변경후,
import React from 'react'

const Login = () => {
return <div>
로그인
</div>
}

export default Login;
default 를 설정안해서 설명부탁드려도 될까요?

클론코딩 babel Socket.io typescript 웹팩 react

Answer 2

1

zerocho

로더블로 import할 컴포넌트는 export default로 설정해두세요.

0

ryosuke kureha

답변감사합니다. 쉬시는 주말에 ㅠㅠ

기본 셋팅과 관련하여

0

106

1

초기 셋팅 back과 front만 남겨두고 다 지운 후 진행 방법

0

109

2

focus 시에만 화면 업데이트 되는 이유 + 해결방법

0

164

2

useEffect 개수 관리

0

122

2

라이브러리 서치 방법

0

118

2

함수 정의 패턴

0

80

1

npm run dev 에러

0

156

3

npx webpack 후 에러

0

186

2

'void' 형식 식의 truthiness를 테스트할 수 없습니다.ts(1345)

0

151

2

사용자 가입시 에러발생 (TypeError: Cannot read properties of null (reading 'addMembers')

1

189

2

초기세팅중 packge.json 에러떠요

0

162

2

CORS - Access-Control-Allow-Origin 누락 문제

0

439

3

로그인 페이지 무한 새로고침 현상

0

607

2

Module not found: Error: Can't resolve './App' 에러

0

967

1

배포 방법

0

305

2

npm run dev 시 빌드가 매우 느려졌습니다

0

1008

2

alias 경로 설정 오류

0

460

2

fetcher 함수의 data 값이 두번 찍히는 이유

0

282

1

제네릭 질문

0

225

2

ts-node 대신 tsx 사용여부

0

377

1

배포 관련 질문

0

249

1

[nginx + https] 서비스를 실행하면 niginx가 아닌 서비스 화면을 보여주게 하고 싶습니다.

0

394

2

[배포하기] webpack에 aws 퍼블릭 IPv4 주소 와 포트 주소를 작성하고 나서 빌드후 실행하면 오류가 발생합니다.

0

341

1

users 호출 시 쿠키가 담기지 않는 이슈 질문드립니다.

0

252

2