4
나는 나의 순수한 기능적 구성 요소에 대한 defaultprops
을 정의 할 수 있지만 형식 오류 얻을 :typescript에서 stateless react 구성 요소에 대한 defaultProps를 정의하는 방법은 무엇입니까?
export interface PageProps extends React.HTMLProps<HTMLDivElement> {
toolbarItem?: JSX.Element;
title?: string;
}
const Page = (props: PageProps) => (
<div className="row">
<Paper className="col-xs-12 col-sm-offset-1 col-sm-10" zDepth={1}>
<AppBar
title={props.title}
zDepth={0}
style={{ backgroundColor: "white" }}
showMenuIconButton={false}
iconElementRight={props.toolbarItem}
/>
{props.children}
</Paper>
</div>
);
Page.defaultProps = {
toolbarItem: null,
};
내가이 쓰기 수 있다는 사실을 알고 :
(Page as any).defaultProps = {
toolbarItem: null,
};
이 defaultProps
를 추가 할 수있는 더 나은 방법이 있나요를?