и вот данные появляются быстрее в редюсере чем в инпутетак и должно быть.
this.updateText = this.eachTask.bind(this);
case 'TOGGLE_COMPLETED':
return Object.assign({}, state, {
todo: state.todo.map((item) => {
if(item.id == action.id) {
item.completed = !item.completed
}
return item;
})
})
openPopup =() => {
<Popup list={this.props.list} />
}
import React from 'react';
import classnames from 'classnames';
class SomeComponent extends React.PureComponent {
constructor(props) {
super(props);
this.onClick = this.onClick.bind(this);
this.state = {
show: false,
};
}
onClick() {
this.setState({ show: !this.state.show });
}
render() {
const { show } = this.state;
return <div onClick={this.onClick} className={classnames('some-class', { 'change-class': show })} />;
}
}
export default SomeComponent;
class MainComponent extends React.Component {
static propTypes = {
activeType: PropTypes.string,
}
static mapStateToProps(state) {
return {
activeType: state.sideBar.activeType,
};
}
// ....
export default connect(
MainComponent.mapStateToProps,
{})(MainComponent);
import { CHANGE_TYPE as SIDEBAR_CHANGE_TYPE } from '../SideBar/constants';
const initState = {
activeType: undefined,
};
export default (state = initState, action) => {
switch (action.type) {
case SIDEBAR_CHANGE_TYPE:
return {
...state,
activeType: action.payload,
};
// ....
default:
return state;
}
};
componentDidMount() {
document.addEventListener('click', this.onClickOutside);
}
componentWillUnmount() {
document.removeEventListener('click', this.onClickOutside);
}
onClickOutside = () => {
this.setState({ visible: false });
}