import React, {Component} from 'react';
import {connect} from 'react-redux';
import {setParamsFromUrl, resetParamsFromUrl} from '../../actions/page/pageActions';

class MyComponent extends Component {
    componentWillMount(){
        if(this.props.match && this.props.match.params){
            this.props.dispatch(setParamsFromUrl(this.props.match.params));
        }else{
            this.props.dispatch(resetParamsFromUrl(this.props.match.params));
        }
    }

    render() {
        const {TagName} = this.props;

        return(<TagName {...this.props}/>);
    }
}

export default connect()(MyComponent);
