import React from 'react';
import Container from '../Container';
import getDisplayName from './getDisplayName';

function defaultTransformProps({ state, actions }) {
  return { ...state, ...actions };
}

export default function container(
  { actions, stores },
  transformProps = defaultTransformProps
) {
  return DecoratedComponent => class ReduxContainerDecorator {
    static displayName = `ReduxContainer(${getDisplayName(DecoratedComponent)})`;

    render() {
      return (
        <Container actions={actions} stores={stores}>
          {props => <DecoratedComponent {...this.props}
                                        {...transformProps(props)} />}
        </Container>
      );
    }
  };
}

import React from 'react';
import Container from '../Container';
import getDisplayName from './getDisplayName';

function defaultTransformProps({ props, state, actions }) {
  return { ...props, ...state, ...actions };
}

export default function container(
  { actions, stores },
  transformProps = defaultTransformProps
) {
  return DecoratedComponent => class ReduxContainerDecorator {
    static displayName = `ReduxContainer(${getDisplayName(DecoratedComponent)})`;

    render() {
      const {props} = this
      
      return (
        <Container actions={actions} stores={stores}>
          {({state, actions}) => <DecoratedComponent {...transformProps({props, state, actions})} />}
        </Container>
      );
    }
  };
}

Allow to transform container props based on component props