如何解决无法在reactjs中的未安装组件警告上调用setState(或forceUpdate)?

时间:2019-02-15 09:44:02

标签: reactjs

我得到警告,无法在未安装的组件上调用setstate。当我从componentdidUpdate的服务器中获取文件并设置状态时,我得到了这个。我这样做是为了自动加载数据而不是页面刷新。我不知道如何避免警告。

下面是代码,

Public Class ParentViewModel
    Public Property Parent As ParentModel
    Public Property ChildViewModel_A As ChildViewModel
    Public Property ChildViewModel_B As ChildViewModel

    Sub New()
        ChildViewModel_A = New ChildViewModel()
        ChildViewModel_B = New ChildViewModel()

        AddHandler ChildViewModel_A.PropertyChanged, AddressOf OnPropertyChangedA
        AddHandler ChildViewModel_B.PropertyChanged, AddressOf OnPropertyChangedB

    End Sub

    Private Sub OnPropertyChangedA(sender As Object, e As PropertyChangedEventArgs)
        Parent.ModelValue_A = ChildViewModel_A.ChildValue
    End Sub

    Private Sub OnPropertyChangedB(sender As Object, e As PropertyChangedEventArgs)
        Parent.ModelValue_B = ChildViewModel_B.ChildValue
    End Sub
End Class

我想做什么?

我使用了_ismount变量来跟踪组件的安装。但是,这不起作用。有人可以帮我这个忙。谢谢。

0 个答案:

没有答案