0
에 대한 유형을 정의하는
코드 :방법 소품
let component = ReasonReact.statelessComponent("Page");
type matchParams = {.
id: int
};
type match = {.
params: matchParams
};
type userProps = {.
match: match
};
let home = <Home />;
let user = (~props:userProps) => <User id=props.match.params.id />;
let make = (_children) => {
...component,
render: (_self) =>
<div> <Route key="home" exact=false path="/home" component=home />
<Route key="user" exact=false path="/user/:id" component=user /> </div>
};
출력 :
약속 레코드 필드 일치 행
유형을 정의하는 방법을let user = (~props:userProps) => <User id=props.match.params.id />;
에
, 내가 뭘 잘못 했니?
반응 라우터의 일치 속성은 일치 단어를 사용할 수없는 경우 어떻게 사용합니까? – kirsanv43
위에서 말한 것처럼 '_match'를 사용하십시오. BuckleScript는 생성 된 코드에서 맨 앞의 밑줄을 제거합니다. https://bucklescript.github.io/bucklescript/Manual.html#_object_label_translation_convention를 참조하십시오. – glennsl