Closed hirenreshamwala closed 2 years ago
I found
import {Component} from "react";
import {EventContext} from "direflow-component";
import PropTypes from 'prop-types';
class App extends Component {
constructor(props, context) {
super(props);
this.dispatchEvent = context;
}
fireExampleEvent() {
let {example} = this.state,
event = new CustomEvent('example', {'detail': 'example data'});
this.dispatchEvent(event);
}
render() {
return (
<>
<button onClick={this.fireExampleEvent.bind(this)}>Click</button>
</>
)
}
}
App.contextType = EventContext;
App.defaultProps = {
name: ''
}
App.propTypes = {
name: PropTypes.string
};
export default App;
Hello,
Any example of React class component with the custom event?