首页 > 解决方案 > 函数运行中的事件发射器回调

问题描述

我正在使用 EventEmitter 触发一个事件,但我无法运行我在此事件中使用的类中的方法。我在哪里做错了,我该如何解决这个问题?

    StaticBase.emitter.addListener('event', this._updateEvent);

_updateEvent(value) {
    if (value.length > 3) {
        this.setState({ keys: value });//---->ERROR function not found, etc .. errors
        this.UpdateList();
    }
}

UpdateList() {
    this.setState({ isLoading: true });
    console.log('POST------>>');
    axios.post('.........')
        .then(response => {
            this.setState({ newlist: response.data });
            this.setState({ isLoading: false });
        }).catch(ex => {
            console.log(ex);
            this.setState({ isLoading: false });
        });
}

标签: react-nativeeventseventemitter

解决方案


推荐阅读