I'm using the react-dragula module with react. For simple explanation purposes, I'm essentially making a trello clone. When an 'AppItem/Card' is moved from one dragula container ('Phase') to another, I want to trigger an event that changes it's 'status' in the db.
My question is where and how do I trigger dragula.on events on 'drop', the docs are for vanilla javascript and I'm not sure how to translate that over to my React component. I've tried writing my DOM events in my constructors, in various component methods, and can not get another to work or even log that an event is happening.
Here are my components that wraps dragula containers that are rendered dynamically
import React from 'react'
import dragula from 'react-dragula'
import Phase from './Phase.jsx'
export default class ProgressBoard extends React.Component{
constructor(props){
super(props)
}
componentDidMount(){
dragula(Array.from(document.getElementsByClassName('phase')))
}
componentDidUpdate(){
dragula(Array.from(document.getElementsByClassName('phase')))
}
render(){
return(
<div className="progressboard-container">
{
this.props.phases.map((phase,i) => <Phase key={i} phase={phase}
applications={this.props.apps.filter(app => app.phase_id ===
phase.id)}/>)
}
</div>
)
}
}
Here is the column/'Phase' component itself
import React, { Component } from 'react'
import Appitem from './AppItem.jsx'
import {Header, Card} from 'semantic-ui-react'
export default class Phase extends Component {
constructor(props){
super(props)
this.state = {}
}
render(){
return(
<div className='phase'>
<div className='PhaseTitle'>
<Header size="large">{this.props.phase.phase_label}</Header>
</div>
{
this.props.applications.map((app,i) => <div app={app} key= .
{i} className="AppItem">{app.company}</div>)
}
</div>
)
}
}