score:0

Using some Domain:

    export type DomainState = Readonly<{
        isLoaded: boolean;
        isLoadedError: boolean;
        model: IDomainModel;
        error: any;
    }>;

    export interface IDomainStore {
        domain: DomainState;
    }

    interface IDomainPageCompProps extends 
        RouteComponentProps<IDomainRoutingParams> {
        isLoadedError: boolean;
        isLoaded: boolean;
        resources: any;
    }

    import { connect } from 'react-redux';
    import { IDomainPageCompProps, DomainPage } from '...';
    import { IDomainStore } from '../store';
    import { RouteComponentProps, withRouter } from 'react-router';
    import { IDomainRoutingParams } from '../types/routing-params';

    interface IOwnProps extends RouteComponentProps<IDomainRoutingParams> {
        resources;
    }

    const connected = connect<IDomainPageCompProps, {}, IOwnProps, IDomainStore>(
        (store: IDomainStore, ownProps: IOwnProps) => {
            return {
                ...ownProps,
                isLoaded: store.domain.isLoaded,
                isLoadedError: store.domain.isLoadedError
            };
        },
        (/* dispatch */) => {
            return {};
        }
    )(DomainPage);
    export const DomainPageContainer = withRouter(connected);


    // .jsx
    <Provider store={store}>
        <DomainPageContainer resources={...} />
    </Provider>

score:0

import * as React from 'react';
import { connect } from 'react-redux';
import { RouteComponentProps } from 'react-router';
import { ApplicationState } from '../store';
import * as CounterStore from '../store/Counter';

interface AdditionalProps {
    exampleProps: string
}

type CounterProps =
    CounterStore.CounterState &
    typeof CounterStore.actionCreators &
    RouteComponentProps<{}> & 
    AdditionalProps;

class Counter extends React.PureComponent<CounterProps> {
    public render() {
        return (
            <React.Fragment>
                <h1>Counter</h1>

                <p>This is a simple example of a React component.</p>

                <p aria-live="polite">Current count: <strong>{this.props.count}</strong></p>

                <p>exampleProps: {this.props.exampleProps}</p>

                <button type="button"
                    className="btn btn-primary btn-lg"
                    onClick={() => { this.props.increment(); }}>
                    Increment
                </button>
            </React.Fragment>
        );
    }
};

export default connect(
    (state: ApplicationState, ownProps: AdditionalProps) => {
        return {
            ...state.counter,
            ...ownProps
        }
    },
    CounterStore.actionCreators
)(Counter as any);

Related Query

More Query from same tag