esamattis / redux-render-prop

Redux with render props. Typescript friendly.
http://npmjs.com/package/redux-render-prop
MIT License
22 stars 0 forks source link

MappedActionsAndState type is missing #22

Closed nkovacic closed 5 years ago

nkovacic commented 5 years ago

MappedActions and MappedState types already exists but a combined type is missing. We now have to merge them by hand. Would be great if this could be added to the main library.


type MappedActionsAndState = MappedActions<typeof MainConnect> & MappedState<typeof MainConnect>;

class Main extends PureComponent<MappedActionsAndState> {
    render() {
        return (
            <View>
                <CustomText>
                    Current route: {this.props.currentRoute}
                </CustomText>
            </View>
        );
    }
}

const MainConnect = createAppConnect({
    mapState: state => ({
        currentRoute: state.routingSelector.currentRouteSelector()
    }),
    mapActions: actions => ({
        changeRoute(route: string) {
            actions.routingActions.changeRoute(route);
        }
    })
});

export default () => (
    <MainConnect>
        {(data, actions) => <Main {...data} {...actions} />}
    </MainConnect>
);
esamattis commented 5 years ago

Why not. Added MappedStateAndActions in the v0.8.1 release.