mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-25 02:57:31 +00:00
Simplifications in ReactSpa and ReactReduxSpa
This commit is contained in:
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user