надеюсь, я ничего не упустил
export class IconStar extends React.Component{
constructor(props) {
super(props);
this.state = {
fill: svgicons.starIcon.deactiv,
className: 'transparent'
}
this.fix_it = this.fix_it.bind(this);
}
fix_it(e){
const { fix, actions } = this.props;
this.setState({
fill: fix ? svgicons.starIcon.deactiv : svgicons.starIcon.active,
className: this.state.class === "transparent" ? "show" : "transparent";
});
actions.fixation();
}
render(){
const { className, fill } = this.state;
return(
<div>
<svg
className={`star_icon ${className}`}
aria-labelledby="title"
onClick={this.fix_it}
>
<title id="title">Нажмите, чтобы закрепить вверху списка</title>
<path d={fill} />
</svg>
</div>
)
}
}
function fixation(){
return (dispatch, getState) => {
let state = getState();
if (!state.controlR.fix) {
dispatch({ type : 'FIX_IT', fix : true });
}
else {
dispatch({ type : 'FIX_IT', fix : false });
}
};
}
const actionCreators = { fixation: fixation };
export default connect(
state => ({ fix : state.controlR.fix }),
dispatch => { actions: bindActionCreators(actionCreators, dispatch) }
)(IconStar);