TypeError:无法读取null的属性“ _currentElement”-setState

时间:2019-07-10 00:05:48

标签: reactjs react-redux

我试图在调度调用后在componentWillMount中设置状态。 其抛出错误,TypeError: Cannot read property '_currentElement' of null

它在我的页面之一中工作,但在该页面中引发错误。

     constructor(props) {
        super(props);
        this.state={
            historyList: []
        }
    }

    componentWillMount() {
        return this.context.store.dispatch(getHistory())
            .then(response => {
                let history = response;
                this.setState({
                    historyList : history
                });
            })
            .catch(err => console.log(err));
    }

当我查看响应时,它具有正确的数据,但在

中给出了错误
this.setState({ historyList : history });

我在做什么错了?

0 个答案:

没有答案