1
私はwithRouter
が私のコンポーネントに固有の小道具を注入するために期待される次の基本的な構成要素実験的デコレータとタイプを調整するにはどうすればいいですか?
import * as React from 'react';
import { withRouter, RouteComponentProps } from 'react-router-dom';
export interface Props { };
@withRouter
export default class Movies extends React.PureComponent<Props> {
goBack =() => {
this.props.history.goBack();
};
public render() {
return (
<div>
<button onClick={this.goBack}>Back</button>
</div>
);
}
}
を持っています。しかし、this.props.history
を参照するとき、私はこの取得:
をタイプ定義を追加しますデコレータを使用する適切な方法は何ですか?
これはTS https://github.com/Microsoft/TypeScript/issues/4881で追跡問題です – asosnovsky