export default connect(mapStateToProps, null, null, { withRef: true })(Component);
this.someRefName.getWrappedInstance();
handleChange = e => {
// handler
};
handleChangeDebounced = debounce(handleChange, 300);
<Input onChange={this.handleChangeDebounced} />
Object.keys(notif).map(key => <div key={key}>{key} - {notif[key]}</div>)
_.map(notif, (value, key) => <div key={key}>{key} - {value}</div>)
лучше писать в constructor() чем в render(). т.к bind будет происходить каждый рендер (onClick = {this.func.bind(this))
class BlaBla extends React.Component {
myFuncWIthThis = () => {
....
}
render() {
<button onClick={this.myFuncWithThis}>Click me</button>
}
}
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>
);
}
}
class GroupPage extends Component {
static deleteItem(item){
console.log('item',item)
}
}
...
const SortableItem = SortableElement(({value}) =>
<li className="listStyle">
{value.video.time !== 0 ?
<Button bsStyle="primary" onClick={()=> GroupPage.deleteItem()}>-</Button> : null}
</li>);