홈>
나는<
PrivateRoute >
반응 라우터에 설명 된대로
서류TypeScript 사용. 누구든지 나를 도울 수 있습니까?
반응 라우터 문서의 privateRoute :
const PrivateRoute= ({ component: Component, ...rest })=> (
<Route {...rest} render={props=> (
fakeAuth.isAuthenticated ? (
<Component {...props}/> ) : (
<Redirect to={{pathname: '/login', state: { from: props.location }
}}/> )
)}/>)
다음은 TypeScript 버전입니다 (작동하지 않음).
const PrivateRoute= (theProps: { path: string, component: React.SFC<RouteComponentProps<any> | undefined> | React.ComponentClass<RouteComponentProps<any> | undefined> })=> {
return <Route path={theProps.path} render={props=> (
fakeAuth.isAuthenticated ? (
<React.Component {...theProps} /> <!--**** It will raise error *** --> ) : (
<Redirect to={{
pathname: '/',
state: { from: props.location }
}} /> )
)} />}
<
React.Component {... thisProps} />
옳지 않습니다. 오류 : NodeInvocationException : inst.render가 함수가 아닙니다.
TypeError : inst.render는 함수가 아닙니다.
관련 자료
- reactjs - create-react-app 및 Typescript를 사용할 때 빌드에서 md 파일을로드하는 방법은 무엇입니까?
- networking - 라우터 대신 레이어 3 스위치 사용
- javascript - LitElement 및 Typescript와 함께 @query 사용
- typescript : Typesscript를 사용할 때 사용자 정의 확장을 추가하는 방법
- TypeScript를 사용할 때 Mongoose 컬렉션 모델의 유형은 무엇입니까?
- javascript - ts2339를 해결하는 방법? test-library/react와 함께 typescript 사용
- 속성 접근자를 사용하는 Typescript가 인터페이스를 확인하지 않습니다
- angular - 배열에서 생성자를 사용하기위한 typescript 개선
- javascript - 작업자 로더를 사용하여 웹 워커와 함께 typescript 라이브러리를 만드는 방법
- reactjs - TypeScript를 사용하는 React의 monaco-editor-> 'monaco-editor'모듈을 찾을 수 없음
- void와 함께 함수 인터페이스를 사용할 때 예기치 않은 유형 스크립트 컴파일러 동작
- networking - ubuntu 서버 2004를 라우터로 사용 - 클라이언트에 인터넷 없음
- lerna - typescript와 함께 특정 폴더의 @types 사용
- r - 내 코드를 tidyverse를 사용하여 datatable로 다시 작성하는 방법은 무엇입니까?
- apache - htaccess 규칙을 사용하여 php를 html로 다시 작성하는 방법은 무엇입니까?
- angular - typescript를 사용하여 관찰 가능한 객체 목록에서 필터를 사용할 수 없습니다
- reactjs - useEffect, useState, Typescript를 사용하여 목록을 필터링하는 방법
관련 질문
- javascript : 조건부 렌더링의 유형 문제를 해결하는 방법은 무엇입니까?
- reactjs : 내 OnePage 응용 프로그램은 페이지가 변경될 때마다 다시 로드됩니다.
- reactjs : 반응, 포퍼, 참조 전달 및 조건부 렌더링
- reactjs : 하나의 prop이 true인 경우 다른 react prop을 무시합니다.
- reactjs : code가 정의되지 않은 것을 확인하고 있는데도 typescript가 이 컴파일 오류를 반환하는 이유는 무엇입니까?
- javascript : react-router에서 동적 링크 목록 만들기
- reactjs : useNavigate가 react-router-dom v6이 작동하지 않습니다.
- javascript : IntersectionObserver: 관찰자 시작 및 종료
- reactjs : 반복되는 setState 호출(후크)
- amCharts v5 템플릿 어댑터 예제는 JavaScript가 아닌 TypeScript로 실행될 때 오류가 발생합니다.