almende / vis

⚠️ This project is not maintained anymore! Please go to https://github.com/visjs
7.85k stars 1.48k forks source link

Update items or remove #4298

Open nasir-awan opened 5 years ago

nasir-awan commented 5 years ago

I am using visjs and react-visjs-timeline in our reactjs application. I want to catch onMove, OnRemove etc event and call any other method within component to update items in state or redux store. When I try to do it, it throws an error Uncaught TypeError: .... is not a function

It seems like in onMove, onRemove ... other methods could not be reached within a component.

The items are updated in the timeline, but state items and group are not being updated. Looks like only one way data-binding .... If I change any item in the state, then it updates timeline.

Packages used react-visjs-timeline: 1.5.0 vis version: 4.12.0

Code sample `class TimelineExample extends React.Component {

onMoveItem = ()=>{ console.log('Im moving'); }

onRemoveItem = () => { console.log('Im removing'); }

render() { const options = { height: 350, // px editable: { add: true, remove: true, updateTime: true }, itemsAlwaysDraggable: true, onMove: function (item, callback) {
onMoveItem(); // Error here }, onRemove: function (item, callback) { onRemoveItem(); // Error here }, };

let items = new vis.DataSet([{
  id: 1,
  content: 'First event',
  start: '2014-08-01'
}, {
  id: 2,
  content: 'Second',
  start: '2014-08-08'
}]);

<Timeline
  options = {this.options}
  items={this.items}
/>   

} }`