mirror of
https://github.com/wassname/talk.git
synced 2026-07-02 12:15:40 +08:00
Comment WithEmit
This commit is contained in:
@@ -1,14 +1,18 @@
|
||||
import React from 'react';
|
||||
const PropTypes = require('prop-types');
|
||||
|
||||
/**
|
||||
* WithEmit provides a property `emit: (eventName, value)`
|
||||
* to the wrapped component.
|
||||
*/
|
||||
export default (WrappedComponent) => {
|
||||
class WithEmit extends React.Component {
|
||||
static contextTypes = {
|
||||
eventEmitter: PropTypes.object,
|
||||
};
|
||||
|
||||
emit = (eventName, value, context) => {
|
||||
this.context.eventEmitter.emit(eventName, value, context);
|
||||
emit = (eventName, value) => {
|
||||
this.context.eventEmitter.emit(eventName, value);
|
||||
};
|
||||
|
||||
render() {
|
||||
|
||||
Reference in New Issue
Block a user