Skip to content
This repository has been archived by the owner on Jun 5, 2020. It is now read-only.

Allow having empty arrays of actions and states, which is the initial behaviour of the extension #22

Merged
merged 1 commit into from
Mar 28, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/DevtoolsInspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ function getCurrentActionId(props, state) {
function createState(props, state) {
const { supportImmutable, computedStates, actionsById: actions } = props;
const currentActionId = getCurrentActionId(props, state);
const currentAction = actions[currentActionId].action;
const currentAction = actions[currentActionId] && actions[currentActionId].action;

const fromState = currentActionId > 0 ? computedStates[currentActionId - 1] : null;
const toState = computedStates[currentActionId];

const fromInspectedState = fromState &&
getInspectedState(fromState.state, state.inspectedStatePath, supportImmutable);
const toInspectedState =
getInspectedState(toState.state, state.inspectedStatePath, supportImmutable);
toState && getInspectedState(toState.state, state.inspectedStatePath, supportImmutable);
const delta = fromState && toState && DiffPatcher.diff(
fromInspectedState,
toInspectedState
Expand All @@ -33,7 +33,7 @@ function createState(props, state) {
return {
delta,
currentActionId,
nextState: getInspectedState(toState.state, state.inspectedStatePath, false),
nextState: toState && getInspectedState(toState.state, state.inspectedStatePath, false),
action: getInspectedState(currentAction, state.inspectedActionPath, false)
};
}
Expand Down