1
나는 당신이이
<Route exact path="/add" render={props => <Add {...props} type="MyProp" />}/>
같은 구문을 렌더링 사용할 필요가 소품을 통과 생각하지만 여기 HOC을 통과 할 수있는 방법은 무엇입니까?
감사합니다.
나는 당신이이
<Route exact path="/add" render={props => <Add {...props} type="MyProp" />}/>
같은 구문을 렌더링 사용할 필요가 소품을 통과 생각하지만 여기 HOC을 통과 할 수있는 방법은 무엇입니까?
감사합니다.
예, 가능합니다. 자본화 된 변수를 requireAuth(Add)
에 할당하십시오.
const AuthAdd = requireAuth(Add);
<Route
exact
path="/add"
render={props => <AuthAdd {...props} type="MyProp" />}
/>;
withRouter
을 사용하십시오.
<Route exact path="/add" component={withRouter(Add)} />
Add
클래스에서는 라우터 소품에 액세스 할 수 있습니다.