const mapStore = createStore(
rootReducer,
compose(
applyMiddleware(thunk),
window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__() : f => f,
)
);
и вот данные появляются быстрее в редюсере чем в инпутетак и должно быть.
this.updateText = this.eachTask.bind(this);
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 });
}
Observable.interval(3000)
.do(value => console.log('attempt #', value))
.switchMap(() => Observable.defer(() => this.http.get(url))
.map(data => data)
.catch(err => console.log(err))
)
.catch (err => Observable.empty())
.subscribe(data => console.log(data));
import React from 'react';
import DatePickerDialog from 'material-ui/DatePicker/DatePickerDialog';
export default class SomeComponent extends React.Component {
constructor(props, context) {
super(props, context);
this.closeDatePicker = this.closeDatePicker.bind(this);
this.openDatePicker = this.openDatePicker.bind(this);
}
closeDatePicker() {
this.datePicker.dismiss();
}
openDatePicker() {
this.datePicker.show();
}
render() {
return (
<div>
<button onClick={this.openDatePicker}>Open</button>
<button onClick={this.closeDatePicker}>Close</button>
<DatePickerDialog ref={ref => this.datePicker = ref} />
</div>
);
}
}