import React, { PropTypes } from 'react';
import { connect } from 'react-redux';
import { createStore, bindActionCreators } from 'redux';
import * as helpers from '../helpers';
import * as uiActions from '../services/ui/actions';
class Icon extends React.Component{
constructor(props){
super(props);
}
componentDidMount(){
if (!this.props.icons[this.props.name]){
this.props.uiActions.getIcon(this.props.name);
}
}
componentWillReceiveProps(newProps){
if (this.props.name !== newProps.name && !newProps.icons[newProps.name]){
this.props.uiActions.getIcon(newProps.name);
}
}
render(){
var className = 'icon';
if (this.props.className){
className += ' '+this.props.className;
}
var svg = '';
if (this.props.icons[this.props.name]){
svg = this.props.icons[this.props.name];
}
return ;
}
}
const mapStateToProps = (state, ownProps) => {
return {
icons: (state.ui.icons ? state.ui.icons : {})
}
}
const mapDispatchToProps = (dispatch) => {
return {
uiActions: bindActionCreators(uiActions, dispatch)
}
}
export default connect(mapStateToProps, mapDispatchToProps)(Icon)