Simplifications in ReactSpa and ReactReduxSpa

This commit is contained in:
Steve Sanderson
2017-05-17 12:44:12 +01:00
parent 785e7d48a2
commit e658ee6375
8 changed files with 28 additions and 28 deletions

View File

@@ -5,7 +5,10 @@ import { ApplicationState } from '../store';
import * as CounterStore from '../store/Counter';
import * as WeatherForecasts from '../store/WeatherForecasts';
type CounterProps = CounterStore.CounterState & typeof CounterStore.actionCreators;
type CounterProps =
CounterStore.CounterState
& typeof CounterStore.actionCreators
& RouteComponentProps<{}>;
class Counter extends React.Component<CounterProps, {}> {
public render() {
@@ -22,7 +25,7 @@ class Counter extends React.Component<CounterProps, {}> {
}
// Wire up the React component to the Redux store
export default connect<CounterStore.CounterState, {}, RouteComponentProps<{}>>(
export default connect(
(state: ApplicationState) => state.counter, // Selects which state properties are merged into the component's props
CounterStore.actionCreators // Selects which action creators are merged into the component's props
)(Counter);
)(Counter) as typeof Counter;

View File

@@ -67,7 +67,7 @@ class FetchData extends React.Component<WeatherForecastProps, {}> {
}
}
export default connect<WeatherForecastsState.WeatherForecastsState, {}, WeatherForecastProps>(
export default connect(
(state: ApplicationState) => state.weatherForecasts, // Selects which state properties are merged into the component's props
WeatherForecastsState.actionCreators // Selects which action creators are merged into the component's props
)(FetchData);
)(FetchData) as typeof FetchData;

View File

@@ -1,6 +1,7 @@
import * as React from 'react';
import { RouteComponentProps } from 'react-router-dom';
export default class Home extends React.Component<{}, {}> {
export default class Home extends React.Component<RouteComponentProps<{}>, {}> {
public render() {
return <div>
<h1>Hello, world!</h1>