私はhttps://github.com/Microsoft/TypeScript-React-Starterのガイドに従ってプロジェクトをセットアップしましたが、反応コンポーネントを関数として持つ例がありました。 これは私が今持っているコードです:このreact-redux関数コンポーネントをクラスコンポーネントに書き直します
export interface Props {
name: string;
enthusiasmLevel?: number;
onIncrement?:() => void;
onDecrement?:() => void;
}
function SessionList({ name, enthusiasmLevel = 1, onIncrement, onDecrement }: Props) {
return (
<div className="App">
hello {name}
</div>
);
}
export function mapStateToProps({ enthusiasmLevel, languageName }: StoreState) {
return {
enthusiasmLevel,
name: languageName,
};
}
export function mapDispatchToProps(dispatch: Dispatch<actions.EnthusiasmAction>) {
return {
onIncrement:() => dispatch(actions.incrementEnthusiasm()),
onDecrement:() => dispatch(actions.decrementEnthusiasm()),
};
}
export default connect(mapStateToProps, mapDispatchToProps)(SessionList);
そして、私はそれが私はタイプの問題とコンパイルエラーのすべての種類を取得しています
class SessionList extends React.Component<any>{
で動作するように適応する方法を学習したいと思います。 これを設定する方法や原則はありますか?クラスコンポーネントに変換