状态更新后,React元素不会呈现

时间:2017-04-11 11:08:03

标签: reactjs redux react-redux

我正在构建react / redux应用程序。我的问题是我无法获取页面来呈现更新的redux对象。我的猜测是我正在做一些事情"非法"在减速机中。

我有以下容器元素,它是各种反应元素的容器包装器。:

// Actions to add: ADD_POINTS, EDIT_SCORE, START_TIME, STOP_TIME,
import {TOGGLE_NOTE_VALUE} from '../constants/actionTypes';
import objectAssign from 'object-assign';
import initialState from './initialState';

export default function rhythmReducer(state = initialState.rhythm, action) {
  let newState = objectAssign({}, state);
  switch (action.type) {
    case TOGGLE_NOTE_VALUE:
        let meter = newState.meters[action.meterId][action.voice].map((note, index) => {
            if (index == action.noteId) {
                console.log(note.value);
                 return Object.assign({}, note,
                    { duration: note.duration, value: !note.value})
            }
            return note
        });
        let meters = state.meters.map(value => Object.assign({}, value));
        meters[action.meterId][action.voice] = meter;
        return Object.assign({}, state, {
           meters: meters
        });
    default:
      return newState;
  }
}

我的减速机如下:

export default {
  rhythm: {
    meters: [
      {
        crash: [
        {
          duration: 16,
          value: true,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
      ],
      hihat: [
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: true,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: true,
        },
        {
          duration: 16,
          value: false,
        },{
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: true,
        },
        {
          duration: 16,
          value: false,
        },{
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: true,
        },
        {
          duration: 16,
          value: false,
        },
      ],
      ride: [
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: true,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: true,
        },
        {
          duration: 16,
          value: false,
        },{
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: true,
        },
        {
          duration: 16,
          value: false,
        },{
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: true,
        },
        {
          duration: 16,
          value: false,
        },
      ],
      htom1: [
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: true,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: true,
        },
        {
          duration: 16,
          value: false,
        },{
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: true,
        },
        {
          duration: 16,
          value: false,
        },{
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: true,
        },
        {
          duration: 16,
          value: false,
        },
      ],
      htom2: [
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: true,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: true,
        },
        {
          duration: 16,
          value: false,
        },{
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: true,
        },
        {
          duration: 16,
          value: false,
        },{
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: true,
        },
        {
          duration: 16,
          value: false,
        },
      ],
      ltom: [
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: true,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: true,
        },
        {
          duration: 16,
          value: false,
        },{
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: true,
        },
        {
          duration: 16,
          value: false,
        },{
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: true,
        },
        {
          duration: 16,
          value: false,
        },
      ],
      snare: [
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: true,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: true,
        },
        {
          duration: 16,
          value: false,
        },{
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: true,
        },
        {
          duration: 16,
          value: false,
        },{
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: true,
        },
        {
          duration: 16,
          value: false,
        },
      ],
      bdrum: [
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: true,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: true,
        },
        {
          duration: 16,
          value: false,
        },{
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: true,
        },
        {
          duration: 16,
          value: false,
        },{
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: false,
        },
        {
          duration: 16,
          value: true,
        },
        {
          duration: 16,
          value: false,
        },
      ],
    },
    ],
  }
};

对象已更新,但页面中没有重新渲染。

初始对象是:

SELECT id
FROM table1 
WHERE yacht_id NOT IN (SELECT id FROM table2) 
   OR yacht_id NOT IN (SELECT id FROM table3)

0 个答案:

没有答案