即使改变状态,setState也不会在React中触发重新渲染

时间:2018-03-10 00:32:32

标签: reactjs react-redux state

我目前正在尝试在Redux-Form中两次渲染子组件并出现以下问题。单击按钮并更新状态后,子组件的第一个实例可以毫无问题地呈现。但是,单击按钮并更新状态后,组件的第二个实例不会呈现。此外,在单击第二个按钮后,当我单击组件的第一个实例的div内的按钮时,它会使用我传递给它的道具呈现第二个子组件。这是我的代码:

    # Total score calculation Team 1
    if not (instance.team_1_first_halftime_score is None):
        if instance.team_1_first_halftime_score >= 0:
            instance.team_1_total_score = instance.team_1_first_halftime_score
            if not (instance.team_1_second_halftime_score is None):
                if instance.team_1_second_halftime_score >= 0:
                    instance.team_1_total_score = instance.team_1_first_halftime_score + instance.team_1_second_halftime_score
                    if not (instance.team_1_shootout_score is None):
                        if instance.team_1_shootout_score >= 0:
                            instance.team_1_total_score = instance.team_1_first_halftime_score + instance.team_1_second_halftime_score + instance.team_1_shootout_point
    # Total score calculation Team 2
    if not (instance.team_2_first_halftime_score is None):
        if instance.team_2_first_halftime_score >= 0:
            instance.team_2_total_score = instance.team_2_first_halftime_score
            if not (instance.team_2_second_halftime_score is None):
                if instance.team_2_second_halftime_score >= 0:
                    instance.team_2_total_score = instance.team_2_first_halftime_score + instance.team_2_second_halftime_score
                    if not (instance.team_2_shootout_score is None):
                        if instance.team_2_shootout_score >= 0:
                            instance.team_2_total_score = instance.team_2_first_halftime_score + instance.team_2_second_halftime_score + instance.team_2_shootout_point

0 个答案:

没有答案